Page 1 of 1
CMYK Value Conversion
Posted: 2008-06-27T02:34:16-07:00
by haeb
Hi all,
i am investigating in a way to convert a cmyk value to rgb value within a webpage (php). For example i want to convert cmyk(0,50,100,5) to rgb(234,140,28).
There are conversion scripts which are converting cmyk to rgb mathematical. The results are not satisfying. I think i have to use color spaces for a better result like, for example Photoshop does it. But i don't have any idea to realize it.
Is there a way to use ImageMagick for this job?
Thanks
Horst
Re: CMYK Value Conversion
Posted: 2008-06-27T16:25:39-07:00
by fmw42
convert -size 1x1 xc:"hsl(180,50%,50%)" txt:
Returns:
# ImageMagick pixel enumeration: 1,1,65535,rgb
0,0: (16384,49151,49151) #4000BFFFBFFF rgb(25%,75%,75%)
Re: CMYK Value Conversion - SOLUTION
Posted: 2008-06-28T01:27:14-07:00
by haeb
Hi fmw42,
thank you for your suggestion. But your code does not work on cmyk:
convert -size 1x1 xc:"cmyk(0%,50%,100%,5%)" txt:
Returns:
# ImageMagick pixel enumeration: 1,1,65535,CMYK
0,0: ( 0,32768,65535, 3277) #00008000FFFF0CCD cmyk(0%,50.0008%,100%,5.00038%)
I have found the solution using color profiles:
convert -size 1x1 xc:"cmyk(0%,50%,100%,5%)" -profile EuropeISOCoatedFOGRA27.icc -profile sRGBColorSpace.icm txt:
Returns:
# ImageMagick pixel enumeration: 1,1,65535,RGB
0,0: (59966,36832, 3) #EA3E8FE00003 rgb(91.5023%,56.202%,0.00457771%)
Regards
Horst
Re: CMYK Value Conversion
Posted: 2008-06-28T11:21:14-07:00
by fmw42
sorry somehow I thought you needed hsl not cmyk
It is interesting that the same technique does not convert cmyk to rgb.
However, it does work by adding -colorspace RGB.
convert -size 1x1 xc:"cmyk(0%,50%,100%,5%)" -colorspace RGB txt:-
# ImageMagick pixel enumeration: 1,1,65535,rgb
0,0: (62258,31129, 0) #F33279990000 rgb(95%,47.5%,0%)
(adding the -colorspace RGB also works with hsl colors, e.g.
convert -size 1x1 xc:"hsl(180,50%,50%)" -colorspace RGB txt:)
Checking at
http://web.forret.com/tools/color.asp using decimal fractions for cmyk and converting rgb values from range 0-255 to percent, I get 94.9%,47.5%,0%. The difference between your values and these are probably due to the -profile