possible bug converting CMYK tiff to RGB tiff

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug converting CMYK tiff to RGB tiff

Post by fmw42 »

See viewtopic.php?f=1&t=28259#p125363 and subsequent posts for best explanation. The original image is at the very first post in the topic.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug converting CMYK tiff to RGB tiff

Post by magick »

It looks like Photoshop displays the original CMYK colors, not the sRGB colors. To achieve, try
  • convert Original.tif -negate new.tif
    display new.tif
New.tif should show the same colors as your whatIseeinPhotoshop.png image. To convert to sRGB, use
  • convert Original.tif -negate -colorspace sRGB new.tif
    display new.tif
Those colors are very different because they are actually in the sRGB colorspace.

Why the negate? Because Photoshop has historically (and incorrectly) reversed the CMYK color values.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug converting CMYK tiff to RGB tiff

Post by fmw42 »

magick wrote:convert Original.tif -negate -colorspace sRGB new.tif
This does not work for me. It still has the orange color rather than brown.

see viewtopic.php?f=1&t=28259&start=15#p125368
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug converting CMYK tiff to RGB tiff

Post by magick »

The CMYK colors appear to match those of whatIseeinPhotoshop.png so that's our baseline color values. For sRGB you would need a CMYK to sRGB color transform that matches that of Photoshop. Since there is a conflict with the associated color profiles, you can eliminate one or use your own. For example:
  • convert Original.tif +profile "*" -profile cmyk.icm -profile sRGB.icm new.tif
If that does not match, you likely do not have the same color profiles as Photoshop. Its also possible, Photoshop is pulling metadata from the XMP profile and perhaps adjusting the color values pre or post color transform.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug converting CMYK tiff to RGB tiff

Post by fmw42 »

These two work by stripping all profiles as I said before

Code: Select all

convert Original.tif[0] -strip -profile /Users/fred/images/profiles/USWebCoatedSwop.icc -profile /Users/fred/images/profiles/sRGB.icc Original_rgb2.tif

Code: Select all

convert Original.tif[0] +profile "*" -profile /Users/fred/images/profiles/USWebCoatedSwop.icc -profile /Users/fred/images/profiles/sRGB.icc Original_rgb2.tif
But I cannot just strip the imbedded USWebCoatedSwop.icc profile and get it to work as follows:

Code: Select all

convert Original.tif[0] +profile "icc" -profile /Users/fred/images/profiles/USWebCoatedSwop.icc -profile /Users/fred/images/profiles/sRGB.icc Original_rgb2.tif

IM either needs to reset the Photoshop data to properly identify that it is then sRGB and not CMYK or it needs some way to strip the Photoshop data alone, so that any color profile and clip paths can remain.

I had tried +profile "xmp" and +profile "tiff", but neither of them worked. So the problem is in the photoshop data, which has no profile listed in the file. I do not know where that data is stored, but -strip or +profile "*" does get rid of it.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug converting CMYK tiff to RGB tiff

Post by fmw42 »

CORRECTION: The above commands to strip profiles do work to get the colors correct, but the transparency is lost.
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: possible bug converting CMYK tiff to RGB tiff

Post by 246246 »

fmw42 wrote: I had tried +profile "xmp" and +profile "tiff", but neither of them worked. So the problem is in the photoshop data, which has no profile listed in the file. I do not know where that data is stored, but -strip or +profile "*" does get rid of it.
+profile "tiff" does nothing. You have to select from the following shown in idntify -verbose

...
Profiles:
Profile-8bim: 7414 bytes
Profile-icc: 557168 bytes
Profile-tiff:37724: 180740 bytes
Profile-xmp: 36672 bytes

+profile tiff:37724 will remove photoshop layer, but photoshop-only transparency information is also in it.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug converting CMYK tiff to RGB tiff

Post by fmw42 »

Thanks for the information about +profile tiff:37724. But we need a way to remove the colorspace information in the photoshop data without destroying the transparency.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug converting CMYK tiff to RGB tiff

Post by fmw42 »

This finally works.

But it should not be necessary to for this to be so complicated. IM should do a proper conversion in a simple command.

Code: Select all

convert -quiet -respect-parenthesis Original.tif \
\( -clone 0 -evaluate set 0 \) \
\( -clone 1 -alpha extract \) \
\( -clone 2 -clone 3 -layers merge +repage \) \
-delete 2,3 \
\( -clone 0 +profile tiff:37724 -alpha off \
	-profile /Users/fred/images/profiles/USWebCoatedSwop.icc \
	-profile /Users/fred/images/profiles/sRGB.icc +repage \) \
-delete 0,1 \
+swap -alpha off -compose copy_opacity -composite \
-define tiff:alpha=associated  \
Original_srgb.tif
Post Reply