Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect conversion from JPG CMYK => RGB (using Image Magick convert works) #4

Closed
jxtps opened this issue Apr 23, 2010 · 13 comments
Closed

Comments

@jxtps
Copy link

jxtps commented Apr 23, 2010

When converting a JPG that is in the CMYK colorspace to the RGB colorspace using RMagick, the operation produces an image that looks like it has inverted colors (black turns to white). Using the Image Magick convert tool does not exhibit this problem. Sample image for which this happens together with the outputs are unfortunately not attached since github doesn't seem to support attachments for bugs. Email me for the files.

Version information and steps to reproduce listed below:

Platform: Ubuntu 9.10 (Karmic)

bugreport$ ruby --version
ruby 1.9.1p376 (2009-12-07 revision 26041) [x86_64-linux]

RMagick command sequence:

bugreport$ irb 
irb(main):001:0> require 'RMagick'
=> true
irb(main):002:0> puts Magick::Long_version
This is RMagick 2.12.2 ($Date: 2009/09/15 22:09:44 $) Copyright (C) 2009 by Timothy P. Hunter
Built with ImageMagick 6.6.0-0 2010-03-03 Q8 http://www.imagemagick.org
Built for ruby 1.9.1
Web page: http://rmagick.rubyforge.org
Email: rmagick@rubyforge.org
=> nil
irb(main):003:0> fn = 'original.jpg'
=> "original.jpg"
irb(main):004:0> orig = Magick::Image.read(fn).first
=> original.jpg JPEG 600x387 600x387+0+0 DirectClass 8-bit 849kb
irb(main):005:0> orig.colorspace
=> CMYKColorspace=12
irb(main):006:0> orig.colorspace = Magick::RGBColorspace
=> RGBColorspace=1
irb(main):007:0> orig.write('original_rmagick_rgb.jpg')
=> original.jpg=>original_rmagick_rgb.jpg JPEG 600x387 600x387+0+0 DirectClass 8-bit 724kb
irb(main):008:0> 

Image Magick convert command sequence:

bugreport$ convert --version
Version: ImageMagick 6.6.0-0 2010-03-03 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP 

bugreport$ convert original.jpg -colorspace rgb original_convert_rgb.jpg
@baror
Copy link
Collaborator

baror commented Apr 28, 2010

Thanks for the details! This looks like an issue that has been affecting several people lately. We'll look into it as soon as we have a free moment, hopefully this weekend.

@baror
Copy link
Collaborator

baror commented May 3, 2010

It looks like the issue was caused by an ImageMagick function change in version 6.5.1 and forward. RMagick in source should be fixed to use the new function when available, and the change will be in the next release.

If you can, please try to compile from source and see if the fix works for you. If not, please reopen.

@jxtps
Copy link
Author

jxtps commented Jun 9, 2010

I cloned rmagick from github and followed the instructions on http://github.com/rmagick/rmagick/blob/master/README.rc but still got the same result as before.

How can I confirm that I'm indeed running the rmagick built from source? Long_version reports (I had separately upgraded to the latest gem using sudo gem install rmagick, so I was already on 2.13.1):

This is RMagick 2.13.1 ($Date: 2009/12/20 02:33:33 $) Copyright (C) 2009 by Timothy P. Hunter
Built with ImageMagick 6.6.2-3 2010-06-08 Q8 http://www.imagemagick.org
Built for ruby 1.9.1
Web page: http://rmagick.rubyforge.org
Email: rmagick@rubyforge.org

@baror
Copy link
Collaborator

baror commented Jun 10, 2010

If you're running RMagick from source, the version of RMagick should be 0.0.0 (since it's unreleased). You may need to remove the RMagick gem before doing an install from source.

@jxtps
Copy link
Author

jxtps commented Jun 10, 2010

Fix worked, thanks!

@thijsc
Copy link

thijsc commented Sep 6, 2010

It would be nice to have an official release with this fix, any plans for that?

@mltsy
Copy link

mltsy commented May 10, 2011

Yes - a release with this fix would be greatly appreciated! :)

@gucki
Copy link

gucki commented Nov 3, 2011

This bug seems to be present again :(

@beirigo
Copy link

beirigo commented Nov 10, 2011

yes i can confirm that the bug is present again =/

@lukesutton
Copy link

This bug is still present in 2.13.1

Is there at least a known work around?

@schneikai
Copy link

here too. using 2.13.1

@schneikai
Copy link

got it working like this:

# source image must have a cmyk color profile. if not, you have to assign a standard profile.
# you get those icc profiles on the interwebs
unless image.color_profile
  image.add_profile("#{Rails.root}/lib/USWebCoatedSWOP.icc")
end

# then you assing a rgb profile. this converts the image to rgb.
image.add_profile("#{Rails.root}/lib/sRGB.icc") 

# you dont need the profiles anymore
image.strip!

@pedrocss
Copy link

schneikai: solution not worked for me. Using RMagic 2.13.1 and sRGB v4 profile.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants