Search code examples
rubyrmagick

Change pixel color in Rmagick


I know how to get the color of a pixel with Rmagick:

image.pixel_color(0,0).

But, how do you change the value of that pixel?


Solution

  • pixel_color takes a third arguments which is the color to use for the current pixel. This can be either a color name like 'white' or an instance of Pixel.

    Example: img = image.pixel_color(0,0, 'white')