sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Converting image from CMYK to sRGB, some colors are incorrect?

Open hdwong opened this issue 5 years ago • 8 comments

I have a jpeg image with CMYK mode and it does not have ICC profile embedded in the metadata. I want to simply convert it to sRGB mode.

// Sharp version 0.26.0
sharp('path-to-original.jpg').toFile('path-to-result.jpg');
original Load and save by Sharp

The background color of the original image is pure black (#000000), but the background is brighter than the original in the result (#1f1f26 on my MacBook monitor).

Pure black is a safety color between CMYK and sRGB, so I think the result is incorrect.

I tried to convert it in Little CMS command jpgicc or Photoshop, the background color after conversion is pure black (#000000).

ORIGINAL URL: https://designer2.s3.us-west-1.amazonaws.com/resource/images/1/z3LqaAfESHVdtVVoJwODUWQW0BWPT1qL.jpg

hdwong avatar Sep 13 '20 02:09 hdwong

CMYK input missing an embedded profile will fallback to using https://github.com/libvips/libvips/blob/master/libvips/colour/profiles/cmyk.icm

A CMYK value of (0,0,0,100) will only be the same as an RGB value of (0,0,0) if the profile says so, but this is usually not the case.

https://en.wikipedia.org/wiki/Rich_black

https://graphicdesign.stackexchange.com/questions/2984/what-kind-of-black-should-i-use-when-designing-for-cmyk-print

lovell avatar Sep 13 '20 08:09 lovell

Thank you for your help @lovell, I learned more knowledge about the color difference between printing and display.

But there is another question, why LittleCMS and Photoshop can convert the result correctly I expected?

hdwong avatar Sep 14 '20 04:09 hdwong

Did you try the https://github.com/libvips/libvips/blob/master/libvips/colour/profiles/cmyk.icm profile with LittleCMS?

lovell avatar Sep 14 '20 07:09 lovell

I tried to use cmyk.icm from the libvips library as the input profile for jpgicc conversion, and the result was not quite correct too (#01000d on MacBook monitor), but it was very close to pure black.

And the cmyk.icc I used before was downloaded from Adobe official website : USWebCoatedSWOP.icc.zip

hdwong avatar Sep 14 '20 09:09 hdwong

What flags are you passing to jpgicc at the command line, e.g. which rendering intent -t and/or black point compensation -b etc?

lovell avatar Sep 17 '20 12:09 lovell

jpgicc -i cmyk.icc -o srgb.icc path-to-original.jpg path-to-result.jpg

hdwong avatar Sep 22 '20 08:09 hdwong

@hdwong Were you able to make any progress with this?

lovell avatar Dec 03 '20 15:12 lovell

Sorry, @lovell, I haven't make any progress on this issue. I still use the jpgicc command to convert the image from CMYK to RGB to make sure the colors are correct.

What about you?

hdwong avatar Dec 07 '20 06:12 hdwong

Let's track this at #1324, as I think what is required is the ability to provide a custom CMYK input profile.

lovell avatar Aug 24 '22 15:08 lovell