Page 1 of 1

CMYK->sRGB conversion fails without any error

Posted: 2013-06-05T05:24:52-07:00
by MaximeLemanissier
Hi all,

I'm using IM to convert CMYK images to sRGB with this command line:
convert input.jpg -profile sRGB_v4_ICC_preference.icc output.jpg
The ICC profile comes from http://www.color.org/srgbprofiles.xalter

On some images, the conversion produces an image that is still a CMYK.
Here is an example on 2 CMYK images, one successfully converted, and one not:
identify imagesToConvert/*
imagesToConvert/7853680641.jpg JPEG 2362x1174 2362x1174+0+0 8-bit CMYK 1.314MB 0.000u 0:00.000
imagesToConvert/7853680970.jpg[1] JPEG 600x220 600x220+0+0 8-bit CMYK 74.6KB 0.000u 0:00.000

./im-6.8.5.9/bin/convert imagesToConvert/7853680641.jpg -quality 95 -profile sRGB_v4_ICC_preference.icc images-srgb/7853680641.jpg
./im-6.8.5.9/bin/convert imagesToConvert/7853680970.jpg -quality 95 -profile sRGB_v4_ICC_preference.icc images-srgb/7853680970.jpg

identify images-srgb/*
images-srgb/7853680641.jpg JPEG 2362x1174 2362x1174+0+0 8-bit sRGB 360KB 0.000u 0:00.000
images-srgb/7853680970.jpg[1] JPEG 600x220 600x220+0+0 8-bit CMYK 147KB 0.000u 0:00.000
If I add a "-colorspace sRGB", all the CMYK images are correctly converted to sRGB but when displayed, colorimetry is wrong (too saturated).

I've reproduced this issue with all IM versions I've tested, including the latest (6.8.5-9).

Any help appreciated.
Regards,

Maxime

Re: CMYK->sRGB conversion fails without any error

Posted: 2013-06-05T07:21:11-07:00
by GreenKoopa
All of your input CMYK images have 4 channels. Do they all have embedded color profiles?

Re: CMYK->sRGB conversion fails without any error

Posted: 2013-06-05T07:58:07-07:00
by MaximeLemanissier
With the CMYK image that gets correctly converted:
identify -verbose /data/iprod/imagesToConvert/7853680641.jpg | grep -i profile
Profiles:
Profile-8bim: 12804 bytes
Profile-exif: 5461 bytes
Profile-icc: 557168 bytes
Profile-iptc: 7 bytes
Profile-xmp: 4030 bytes
With the CMYK image that is not converted:
identify -verbose /data/iprod/imagesToConvert/7853680970.jpg | grep -i profile
(nothing)
So I guess the answer is that an embedded color profile is needed in the input image to perform CMYK -> sRGB conversion.
If not, I can try with -colorspace RGB but output image will likely have wrong colors.
Correct?

Shouldn't IM fail with an error message and return code different from 0 when asking a profile conversion that isn't / can't be done?

Re: CMYK->sRGB conversion fails without any error

Posted: 2013-06-05T08:16:26-07:00
by MaximeLemanissier
MaximeLemanissier wrote:Shouldn't IM fail with an error message and return code different from 0 when asking a profile conversion that isn't / can't be done?
OK, I've found some clues why it should not
If the image does not contain an embedded profile then the first -profile option is used to specify the source color profile. The second -profile option is used to specify the destination color profile.
For example:
convert cmyk-with-embedded-profile.esp -profile /path/to/USWebCoatedSWOP.icc -profile /path/to/sRGB.icm my-rgb.jpg

This means that the first command given above will give strange results if the source image does not contain an embedded profile as convert will assume that -profile /path/to/sRGB.icm is specifying the source color profile.
viewtopic.php?f=1&t=8812

Thanks for your help.

Re: CMYK->sRGB conversion fails without any error

Posted: 2013-06-05T08:34:04-07:00
by GreenKoopa
Without a color profile you may not have the desired appearance, conversion or not.

-profile converts if a there is an existing embedded profile, otherwise it can only assign. This behavior seems reasonable to get you to the destination specified, but you're right that it may not make sense in your case of mixing RGB and CMYK. I don't have enough experience here to judge reasonable. -set profile assigns a profile without conversion.