rmagick / rmagick

Ruby bindings for ImageMagick
https://rmagick.github.io/
MIT License
694 stars 140 forks source link

Transform image according to Info#colorspace #1594

Closed Watson1978 closed 2 weeks ago

Watson1978 commented 2 weeks ago

Fix https://github.com/rmagick/rmagick/issues/46

If colorspace is set through Image#colorspace, the image will be transformed properly. However, if use Info#colorspace, it is not. It should be transformed as well.

require 'rmagick'

image = Magick::Image.read('doc/ex/images/Button_0.gif').first
image.colorspace = Magick::GRAYColorspace
image.write('Image_colorspace_eq.gif')

image = Magick::Image.read('doc/ex/images/Button_0.gif') { |info| info.colorspace = Magick::GRAYColorspace }.first
image.write('Info_colorspace_eq.gif')

The result with before changing: