Issues with Color Conversion

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jyelloz

Issues with Color Conversion

Post by jyelloz »

This is probably an LCMS issue but I've been trying to convert a PSD image with ImageMagick from RGB to CMYK using:

Code: Select all

convert -render -layers merge "input.psd"  -black-point-compensation -intent Relative -profile "sRGB Color Space Profile.icm" -profile "USWebCoatedSWOP.icc" "output.tiff"
If I do the same thing with the input image in Adobe Photoshop (Edit->Convert to profile and enable black point compensation and the same profile), I end up with a pretty similar result (Photoshop against ImageMagick) but if the histograms are inspected, they are visibly different.
Also, when I compare each color channel separately, I can see slight differences.

Is there anything else I can do with ImageMagick to get closer results to Photoshop?
I've tried building the latest ImageMagick against the LCMS 2.0 beta 3 and I still have this problem.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Issues with Color Conversion

Post by magick »

What version of ImageMagick are you using? Can you post a URL to your image so we can download and inspect it?
jyelloz

Re: Issues with Color Conversion

Post by jyelloz »

I'm using the latest svn checkout of ImageMagick from trunk (r1774) and lcms 2.0 beta3 on Mac OS X 10.5 Intel.

Here's a zip file containing the original file used (PSD RGB) and the output from ImageMagick and Photoshop.
http://rapidshare.com/files/381636614/C ... s.zip.html

Also, I may have encountered a bug in ImageMagick with profile assignment. When I open the "cmyk from imagemagick.tiff" file in Photoshop, I get a warning about the color profile being invalid. There's no problem when I look at it in Apple's Preview.app, though.
jyelloz

Re: Issues with Color Conversion

Post by jyelloz »

In addition, I tried using the tificc tool in lcms 2.0 on a tiff version of the original psd file (with no color changes) and I got a different result from the other two.
I ran

Code: Select all

tificc -v -t1 -b -e -o "USWebCoatedSWOP.icc" "input.tiff" "output.tiff"
And got a result that didn't match either ImageMagick's or Photoshop's conversion.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Issues with Color Conversion

Post by Drarakel »

jyelloz wrote:Also, I may have encountered a bug in ImageMagick with profile assignment. When I open the "cmyk from imagemagick.tiff" file in Photoshop, I get a warning about the color profile being invalid. There's no problem when I look at it in Apple's Preview.app, though.
I think with PSD files it's recommended to add "-strip" before you assign the color profiles (your input file already shows a sRGB profile!). If I omit -strip, it gives me a result like your "cmyk from imagemagick.tiff", and it almost seems that two color profiles are embedded..? For example: Irfanview opens it alright and shows only the SWOP profile. But ImageMagick/identify shows only a sRGB profile within the CMYK image.(!)
But with -strip in the former command, ImageMagick gives me a valid file (with only the US Web Coated SWOP profile).
jyelloz

Re: Issues with Color Conversion

Post by jyelloz »

The reason I put the sRGB profile at the beginning was to perform a conversion from any other RGB profile. It has no effect on the output image. Both outputs have the same histograms in Photoshop. I would prefer not to use the -strip option because I don't want to re-assign profiles, I want to convert between them. A better option is probably to remove non-icc profiles instead doing something like:

Code: Select all

convert -render -layers merge "input.psd"  -black-point-compensation -intent Relative +profile '!icm,*' -profile "sRGB Color Space Profile.icm" -profile "USWebCoatedSWOP.icc" "output.tiff"'
But that only makes the profile get saved properly. It has no effect on the quality.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Issues with Color Conversion

Post by Drarakel »

jyelloz wrote:+profile '!icm,*'
Just as a side note: In your example, this is the same as "-strip". :wink:
jyelloz

Re: Issues with Color Conversion

Post by jyelloz »

Drarakel wrote:Just as a side note: In your example, this is the same as "-strip". :wink:
Sorry, that was a mistake. I actually use

Code: Select all

+profile '!icm,!icc,*'
to do the conversion.
This seems to keep any ICC/ICM profiles and not keep xmp/iptc/whatever profiles.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Issues with Color Conversion

Post by Drarakel »

It shouldn't do any harm (with two sRGB profiles at the start), but this is not the proper way to do a conversion.
If you want to use the profile of the input file, you don't need the first '-profile profile.icc' part. If you want to add the first profile manually, you should use '-strip' or at least '+profile "icc,icm"' before adding that part.
But: With PSDs, it's generally recommended to use '-strip' before you assign the profiles manually - as the usage of the embedded color profiles is not totally reliable there, I think.
One should always make sure that there are only two color profiles (not more, not less) involved in a such a conversion. The target profile will be automatically saved with your output file, if possible (unless you add another '-strip' or '+profile icc' after your target profile).

Regarding the small color differences in the different conversions.. I can't help you there, sorry.

By the way: The Rapidshare link doesn't work anymore.
xag

Re: Issues with Color Conversion

Post by xag »

Slight differences between color histograms resulting from color-space conversion by Adobe ACE and ImageMagick may result from different conversion "intents", or different algorithms to implement the same intents. The "intent" defines how you deal with colors that exist in one color-space and not in the other. E.g. it says whether you intend to keep most colors unmodified after conversion (colors that exist in both color-spaces) or whether you intend to keep color differences.

In brief, there isn't a unique way to convert.

I don't know if ImageMagick allows for the same intents as Adobe ACE and implements them the same way. I'd be interested to know.
Post Reply