Compositing using CMYK images results in sRGB image

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
chaddjohnson
Posts: 17
Joined: 2018-11-27T20:59:27-07:00
Authentication code: 1152

Compositing using CMYK images results in sRGB image

Post by chaddjohnson »

Hello, after compiling ImageMagick 6.9.10-84 and 7.0.9-14, I am finding that compositing two CMYK images results in a sRGB output image. This is unexpected. With previous ImageMagick versions, compositing two CMYK images would produce a CMYK image.

Here is the command I am using with an older version (6.8.9-9) of ImageMagick on my machine:

Code: Select all

composite input2.jpg large.tif -compose dst_over output.tif
Identify shows this as output:

Code: Select all

output.tif TIFF 2457x2114 2457x2114+0+0 8-bit CMYK 15.8917MiB 0.000u 0:00.002
However, when I used a compiled version (6.9.10-84) with the same composite command as above, identify shows the following output:

Code: Select all

output.tif TIFF 2457x2114 2457x2114+0+0 8-bit sRGB 8654190B 0.000u 0:00.002
The same happens if I output in jpg format: the jpg is also sRGB.

Using "-colorspace CMYK" does not help.

The input input images are definitely CMYK:

Code: Select all

input2.jpg JPEG 2457x2114 2457x2114+0+0 8-bit CMYK 6.25661MiB 0.010u 0:00.002
large.tif TIFF 2457x2114 2457x2114+0+0 8-bit CMYK 670540B 0.000u 0:00.001
These were created using USWebCoatedSWOP CMYK color profile.

Please note that “large.tif” contains alpha / transparency.

Is this by chance a bug? Or did the composite command somehow change recently in ImageMagick?

User avatar
fmw42
Posts: 26261
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Compositing using CMYK images results in sRGB image

Post by fmw42 »

I cannot confirm that it used to work. I am not sure that you can composite in CMYK. I never work in CMYK and much of ImageMagick only works correctly in RGB. But I did test with IM 6.9.10.84 Q16 Mac OSX and the following does fail:

Code: Select all

convert lena.jpg -strip -profile /Users/fred/images/profiles/sRGB.icc -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc lena_cmyk.jpg
convert barn.jpg -strip -resize 50% -profile /Users/fred/images/profiles/sRGB.icc -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc barn_cmyk.jpg
identify lena_cmyk.jpg barn_cmyk.jpg
lena_cmyk.jpg JPEG 256x256 256x256+0+0 8-bit CMYK 605370B 0.000u 0:00.003
barn_cmyk.jpg JPEG 200x150 200x150+0+0 8-bit CMYK 586674B 0.000u 0:00.001

Code: Select all

composite barn_cmyk.jpg lena_cmyk.jpg result.jpg
identify result.jpg
result.jpg JPEG 256x256 256x256+0+0 8-bit sRGB 593902B 0.000u 0:00.002

Code: Select all

convert lena_cmyk.jpg barn_cmyk.jpg -compose over -composite result2.jpg
identify result2.jpg
result2.jpg JPEG 256x256 256x256+0+0 8-bit sRGB 593902B 0.000u 0:00.003

The two result images are, however, color inverted. Identify verbose says that the colorspace is sRGB, but does list the CMYK profile. So it appears that the colorspace is mislabeled.

chaddjohnson
Posts: 17
Joined: 2018-11-27T20:59:27-07:00
Authentication code: 1152

Re: Compositing using CMYK images results in sRGB image

Post by chaddjohnson »

Thanks Fred for reproducing the issue.

I just tested some previous versions of ImageMagick. The issue is not present in 6.9.10-44, while the issue is present in 6.9.10-71. So the issue began sometime between those two versions.

For now I will stick with 6.9.10-44.

User avatar
magick
Site Admin
Posts: 11216
Joined: 2003-05-31T11:32:55-07:00

Re: Compositing using CMYK images results in sRGB image

Post by magick »

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.

chaddjohnson
Posts: 17
Joined: 2018-11-27T20:59:27-07:00
Authentication code: 1152

Re: Compositing using CMYK images results in sRGB image

Post by chaddjohnson »

Thanks magick!

Post Reply