Converting single RGB color value to CMYK with ICC profiles
Posted: 2016-01-14T07:56:11-07:00
I'm sure this has been asked before, but I couldn't find a solution from earlier threads, so here goes: I'm developing a PHP application that deals with color values incoming in RGB and the app should convert them to CMYK. The PHP runs ImageMagick convert command with exec() -function. I've used ImageMagick for some basic image crop/resize -stuff, but I feel that my understanding is a bit lacking here...
For example, let's say that I have RGB color #dfd3c1 which equals 223,211,193. Based on what I found from other threads, I managed to build something like this:
convert xc:"rgb(223,211,193)" -profile sRGB.icc -profile ISOnewspaper26v4.icc -format "%[fx:int(100*c)], %[fx:int(100*m)], %[fx:int(100*y)], %[fx:int(100*k)]\r\n":
The output in percentages should be something like 3,6,16,14, but I'm getting 0.894179%, 5.71908%, 13.8964%, 2.82902%
The questions:
1) What's wrong with the command? Why the values aren't what they _should_ be?
2) In PHP, how can I just "echo" out the value to store the output from the exec to an variable? I managed to make the convert command to write the output to a file, but it would be much easier to have it output as string which I could store to a variable.
For example, let's say that I have RGB color #dfd3c1 which equals 223,211,193. Based on what I found from other threads, I managed to build something like this:
convert xc:"rgb(223,211,193)" -profile sRGB.icc -profile ISOnewspaper26v4.icc -format "%[fx:int(100*c)], %[fx:int(100*m)], %[fx:int(100*y)], %[fx:int(100*k)]\r\n":
The output in percentages should be something like 3,6,16,14, but I'm getting 0.894179%, 5.71908%, 13.8964%, 2.82902%
The questions:
1) What's wrong with the command? Why the values aren't what they _should_ be?
2) In PHP, how can I just "echo" out the value to store the output from the exec to an variable? I managed to make the convert command to write the output to a file, but it would be much easier to have it output as string which I could store to a variable.