Search code examples
rubyrmagick

Replacing a color with rmagick


I'm currently stuck on a - more or less - simple task. I need to replace some colors with other colors in an image using rmagick.

I found two approaches.

  • Looping through every pixel to replace it's color
  • Color to alpha, set background color, save as new image.

Is there a better solution?


Solution

  • Finally, I found the answer myself:

    Using Magick::Image#opaque_channel