Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

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?".
atf4_solace
Posts: 18
Joined: 2017-09-15T07:57:03-07:00
Authentication code: 1151

Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by atf4_solace »

Hello Team,

We are using the Version: ImageMagick 6.9.3-8 Q16 x86_64 2018-06-20 and Platform is LINUX and API is PHP using exec() function.

1. We have one image with colorspace CMYK. Please see below screenshot for that CMYK image
http://prntscr.com/o1c13e

2. We have to convert the colorspace of this image to RGB because the printer is unable to print this CMYK image

3. When we use below command to do this then color gets sharpened as shown in below screenshot:
Command : convert input.jpg -colorspace sRGB output.jpg
Screenshot of RGB image: http://prntscr.com/o1ca2w

So we just want to change the colorspace from CMYK to RGB and preserve the color intensity or preserve the color contrast
How can we do that?

Thank You
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by snibgo »

Please post a link to the actual CMYK file. The critical factor is: does it have an embedded ICC profile? If it doesn't, any conversion to RGB can only be a guess, and there is no "correct" conversion.

Incidentally, I've seen that image before, with a similar "correct" issue.
snibgo's IM pages: im.snibgo.com
atf4_solace
Posts: 18
Joined: 2017-09-15T07:57:03-07:00
Authentication code: 1151

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by atf4_solace »

Thanks for the reply Snibgo

Please see below link for an actual input image
https://ibb.co/34NHSTs

Output image
https://ibb.co/HV2vdM1

So basically image is dynamic for command, any image with any colorspace or with a profile can be input image so in that process, CMYK should convert to RGB but with preserved color values

Thank You
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by snibgo »

The file contains an embedded profile, so you should use "-profile" to convert it, eg:

Code: Select all

magick Channel-digital-image-CMYK-color.jpg -profile sRGB.icc x.jpg
snibgo's IM pages: im.snibgo.com
atf4_solace
Posts: 18
Joined: 2017-09-15T07:57:03-07:00
Authentication code: 1151

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by atf4_solace »

Hello Snibgo,

Thank you for your reply

So we have used your mentioned command for the changing color profile of the image
Your mentioned command:

Code: Select all

magick Channel-digital-image-CMYK-color.jpg -profile sRGB.icc x.jpg
The command we used is as below

Code: Select all

convert input-image.jpeg -profile sRGB.icc output-image.jpg
So please see below output image link for that above command output-image.jpg
https://solaceinfotech.com/imagic_test/output-image.jpg

Please see below link for input-image.jpeg
https://solaceinfotech.com/imagic_test/input-image.jpeg

So could you please let us know is that conversion proper now for our expected output of changing from CMYK to RGB with preserving colors and contrast.

Thank You.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by snibgo »

Your command did not make that output image from that input image.

For one thing, they are different sizes but your command doesn't resize.

For another, your command makes an sRGB image but your output image is CMYK.
snibgo's IM pages: im.snibgo.com
atf4_solace
Posts: 18
Joined: 2017-09-15T07:57:03-07:00
Authentication code: 1151

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by atf4_solace »

Hello Snibgo,

Thanks for the reply,

So you mean the image has an sRGB profile and CMYK colorspace??.

if it's not correct output so could you please tell us what we have missed?

For resized image output that you told we have first made some resizing on image and then used your mentioned command operator -profile

And also tried with directly on the original image without resizing and just checked for changing the color profile of the image

Here is the original image link:
https://solaceinfotech.com/imagic_test/input-image.jpeg

Output image link:
https://i.ibb.co/6rDsnSg/output-image.jpg

Please let us know what we have missed so that profile is not applied with below command and it remains CMYK

Code: Select all

convert input-image.jpeg -profile sRGB.icc output-image.jpg
Thank You
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by snibgo »

Do you have sRGB.icc in your current directory?

Did your convert command complete without error? Insert "-verbose" as the first option. What is the text output?
snibgo's IM pages: im.snibgo.com
atf4_solace
Posts: 18
Joined: 2017-09-15T07:57:03-07:00
Authentication code: 1151

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by atf4_solace »

Hello Snibgo,

Thanks for the reply

As you mentioned for the ICC file to put in the current directory for that we have downloaded the sRGB.icc file and placed in current directory and conversion of CMYK to RGB worked fine for the provided command and thanks for that :) .

We have attached the input image link and output image link of the below command

Code: Select all

convert input.jpeg -profile sRGB.icc output.jpg
1. Input image link:
https://i.ibb.co/WxBvmHq/input.jpg

2. Output image link:
https://i.ibb.co/9n0cjBQ/output.jpg

3. Old output where colorspace changed with -colorspace operator and not -profile operator:
https://i.ibb.co/vJrYgnq/output2.jpg

Now, the input is CMYK and output image is sRGB with sRGB profile and output is much more improved and close to input image but just with the little color difference.

So do we need to make any modifications and adjustments so that output image will be identical with input by means of colors but with different profiles

Appreciates your help.

Thank You.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by snibgo »

atf4_solace wrote:... and output is much more improved and close to input image but just with the little color difference
How do you know there is a colour difference?

Your input.jpg is CMYK with a profile and your output.jpg is sRGB with a profile. Viewing them both with Windows Photo Viewer on a (roughly) sRGB screen I can see no difference.

Windows Photo Viewer regard embedded profiles, and seems to process them correctly.

Your two colorspaces (U.S. Web Coated (SWOP) v2 and sRGB_ICC_v4_Appearance) have different gamuts, meaning some colours can be represented in one colorspace but not the other, so colours don't map 1:1. The ICC give four methods for coping with this; see http://www.imagemagick.org/script/comma ... php#intent and http://www.color.org/iccprofile.xalter . The methods are commonly available in software, but they are not defined standards, so different software can do different things even when the same intent is specified.

When you say "but just with the little color difference", I suspect you are comparing IM's conversion from CMYK to sRGB with another software's conversion from CMYK to sRGB, and viewing the results on a sRGB screen. Perhaps the software systems are using different intents, or perhaps the same intent but different algorithms.
atf4_solace wrote:So do we need to make any modifications and adjustments so that output image will be identical with input by means of colors but with different profiles
In general, the output cannot be identical to the input because the gamuts are different.

If you want to ensure consistent conversion from CMYK to sRGB, always use the same software with the same intent.
snibgo's IM pages: im.snibgo.com
Annalisa
Posts: 11
Joined: 2019-02-07T04:12:59-07:00
Authentication code: 1152

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by Annalisa »

Hi all,
I have a similar problem. When I load in a custom system an image with colorspace CMYK, in the custom system the image has different color.
The color space chanced to sRGB, but the colors are different than CMYK image. Means green color is much darker than rgb image.

The setting for ImageMagick in my custom system are:
-intent relative -flatten -sample 1024x768> -quality 95 -colorspace sRGB -strip -auto-orient

How suggested, I add in the setting : "-profile sRGB.icc".
In this way I have solved the problem for an image with colorspace CMYK, but if I upload in my system an image with colorspace RGB, I don't see the preview.

I have to make both colorspaces work, what can I do?

Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by snibgo »

Please don't multipost. I have removed your other post.

Your question is vague. What version of IM, on what platform?

You have a CMYK image with embedded profile, correct? And "-profile sRGB.icc" converts that correctly to sRGB, correct? What is your final command?
snibgo's IM pages: im.snibgo.com
Annalisa
Posts: 11
Joined: 2019-02-07T04:12:59-07:00
Authentication code: 1152

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by Annalisa »

Hello Snibgo,
Thanks for the reply and sorry for multpost.

IM Version : ImageMagick 7.0.6-5 Q16 x64 2017-08-03
Plattform : OTMM OpenTextMediaManagement
(Note: The original image as uploaded into OTMM is not altered by ImageMagick. Changing the ImageMagick settings will only impact the Thumbnail and Preview image. Now in OTMM the ImageMagick setting are: "-intent relative -flatten -sample 1024x768> -quality 95 -colorspace sRGB -strip -auto-orient" )

Yes, I have a CMYK image with embedded profile and "-profile sRGB.icc" converts that correctly to sRGB.
I mean that if I add "-profile sRGB.icc" in the setting, I correctly visualize the previews of the images in CMYK, but I don't see the previews of the images in RGB.
( new setting : -intent relative -flatten -sample 1024x768> -quality 95 -profile sRGB.icc -colorspace sRGB -strip -auto-orient

I must to find a setting valid for both the colorspace.

I hope you have added useful information.
Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by snibgo »

Annalisa wrote:I must to find a setting valid for both the colorspace.
But what are your input files? Perhaps they are:

1. CMYK with embedded profile.
2. CMYK with no embedded profile.
3. sRGB with embedded profile.
4. sRGB with no embedded profile.

Any others?

(4) needs no conversion.

(1) and (3) can be converted with "-profile sRGB.icc", and not "-colorspace sRGB" or "-strip".

(2) needs guesswork, eg assign a CMYK profile, then as for (1).
snibgo's IM pages: im.snibgo.com
Annalisa
Posts: 11
Joined: 2019-02-07T04:12:59-07:00
Authentication code: 1152

Re: Convert image colorspace to rgb from cmyk without affecting image color contrast or color values

Post by Annalisa »

Yes, I can have those file types.
I understood what you were saying, I investigate with OTMM how to specialize the settings.

Thanks a lot!
Post Reply