Page 2 of 2

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2014-05-26T05:51:10-07:00
by snibgo
Well spotted. I have reported it: viewtopic.php?f=3&t=25633

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2014-05-26T06:03:56-07:00
by tricon
Cool.
I will simply work with the swapped values meantime.

Thanks for the great help :)

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2014-05-26T16:45:32-07:00
by snibgo
The bug occurs when "m" and "y" are used explicitly. Compare and contrast:

convert xc:cmyk(10%,20%,30%,40%) -colorspace CMYK -precision 9 -format "%[fx:100*p{0,0}.c]\%,%[fx:100*p{0,0}.m]\%,%[fx:100*p{0,0}.y]\%,%[fx:100*p{0,0}.k]\%\n" info:

10.000763%,30.000763%,20%,40%

convert xc:cmyk(10%,20%,30%,40%) -colorspace CMYK -precision 9 -format "%[pixel:p{0,0}]\n" info:

cmyk(10.000763%,20%,30.000763%,40%)

EDIT: This is a reply to a post that then vanished.

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2015-08-01T04:27:21-07:00
by sera88
Hi Everyone,

sorry for warming this thread up, but i ran into the same trouble with the exact behaviour.
I tried the upper commands and they work like expected, but the color seems not to be similar like photoshop.
If i run the following command i get cmyk(100,0,0,0) instead of cmyk(80,24,0,0):

Code: Select all

convert xc:rgb\(0,255,255\) -precision 9 -colorspace cmyk -format "%[fx:int(100*c)], %[fx:int(100*m)], %[fx:int(100*y)], %[fx:int(100*k)]\r\n" info:
can someone maybe share some insights how i get the right conversion like in the upper post from Tricon?

Thanks in advance,

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2015-08-01T05:14:10-07:00
by snibgo
See upthread. Tricon was using "-profile" for the conversions, not "-colorspace".

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2015-08-01T05:19:03-07:00
by sera88
wow thanks for the fast reply! :)

i tried it also with the profile:

Code: Select all

convert xc:'rgb(0,255,255)' -profile AdobeRGB1998.icc -profile CoatedFOGRA39.icc -precision 9 -format "%[fx:int(100*c)], %[fx:int(100*m)], %[fx:int(100*y)], %[fx:int(100*k)]\r\n" info:
but if i do so, i get the following i get the following:

Code: Select all

convert: delegate library support not built-in `rgb(0,255,255)' (LCMS) @ warning/profile.c/ProfileImage/849.
convert: ColorSeparatedImageRequired `' @ error/fx.c/FxGetSymbol/1647.
0, 100, 100, 
any ideas, what i can do?

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2015-08-01T05:26:38-07:00
by Bonzo
What operating system are you using and what version of Imagemagick?

Have you tried something simple to ensure Imagemagick is working on your setup?

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2015-08-01T05:31:53-07:00
by sera88
Hi Bonzo,

Its a Imagemagick on a OSX, handled over the Terminal-application. simple image generations are working.
Version: ImageMagick 6.9.1-4

Any ideas?

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2015-08-01T05:33:10-07:00
by snibgo
What does "convert -version" say? It should be something like:

Code: Select all

Version: ImageMagick 6.9.1--6 Q16 x64 2015-06-20 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
If it doesn't say lcms under delegates, that's the problem.

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2015-08-01T06:19:25-07:00
by sera88
Hi snibgo,

THX so much! after reinstall of ImageMagick with littleCMS it works like charme now!! :)

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2015-08-01T06:45:48-07:00
by sera88
Ok, now i'm facing the last problem of the overall topic.

I get now from rgb(0,255,255) the following cmyk(56,0,18,0) value, what is obvious the right one like in photoshop.
But now i need to reconvert it into the right rgb value to visualize it to the customer.

i tried the following:

Code: Select all

convert xc:'cmyk(56,0,18,0)' -profile CoatedFOGRA39.icc -profile sRGB.icc -precision 9 -format "%[fx:int(100*r)], %[fx:int(100*g)], %[fx:int(100*b)]\r\n" info:
but it gives me rgb(81, 91, 94) back what is not correct. It should be something like rgb(85,198,212).

do anyone already figured out how this works?

Best,

Re: Convert color values from RGB to CMYK with ICC profile

Posted: 2015-08-01T11:21:36-07:00
by fmw42
The issue is that you have specified cmyk values in the range 0 to 255, but are requesting results in %. Note that in fx, r=u.r and either is in the range of 0 to 1. So your results are percent and not raw values. To get correspondence, multiply by 255 or use 100 and add %. I am using IM 6.9.1.10 Q16 Mac OSX

Code: Select all

convert xc:'cmyk(56,0,18,0)' \
-set colorspace CMYK -colorspace sRGB \
-precision 4 -format "%[fx:100*r]\%, %[fx:100*g]\%, %[fx:100*b]\%\n" info:
78.04%, 100%, 92.94%

Code: Select all

convert xc:'cmyk(56,0,18,0)' \
-set colorspace CMYK -colorspace sRGB \
-format "%[fx:int(255*r)], %[fx:int(255*g)], %[fx:int(255*b)]\n" info:
199, 255, 237

Code: Select all

convert xc:'cmyk(56,0,18,0)' \
-set colorspace CMYK -colorspace sRGB \
 %[pixel:u.p{0,0}]\n" info:
srgb(199,255,237)

All these results agree with results from the color converter at http://www.imagemagick.org/contrib/color-converter.php

Using profiles will give slightly different result, depending upon the profiles used. For example:

Code: Select all

convert xc:'cmyk(56,0,18,0)' \
-set colorspace CMYK -profile /users/fred/images/profiles/USWebCoatedSWOP.icc \
-profile /users/fred/images/profiles/sRGB.icc \
-format "%[fx:int(255*r)], %[fx:int(255*g)], %[fx:int(255*b)]\n" info:
195, 231, 235