Page 1 of 1

Problem generating CMYK color sample images

Posted: 2011-06-10T02:57:23-07:00
by t.hoepfner
Hi list,

I'm trying to create color sample images for given CMYK values. I'm currently using the following command:

Code: Select all

convert -size 90x90 xc:white -fill "cmyk(255,255,18,97)" -draw "rectangle 0,0 90,90" -colorspace CMYK -type ColorSeparation -depth 8 out.tif
However, the resulting file has a different color. Instead of cmyk(255,255,18,97) I get cmyk(255,255,0,108):

Code: Select all

identify -verbose out.tif
Image: out.tif
...
  Channel statistics:
    Cyan:
      min: 255 (1)
      max: 255 (1)
      mean: 255 (1)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
    Magenta:
      min: 255 (1)
      max: 255 (1)
      mean: 255 (1)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
    Yellow:
      min: 0 (0)
      max: 0 (0)
      mean: 0 (0)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
    Black:
      min: 108 (0.423529)
      max: 108 (0.423529)
      mean: 108 (0.423529)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
...
  Histogram:
      8100: (255,255,  0,108) #FFFF006C yellow
...
Same results on:
MacOS X 10.5.8, ImageMagick 6.6.6-3 Q16
Ubuntu Linux 8.04, ImageMagick 6.7.0-2 Q16

What am I doing wrong?

Thanks for your help,

Timo

Re: Problem generating CMYK color sample images

Posted: 2011-06-10T06:40:44-07:00
by t.hoepfner
Hi again,

it appears that -draw always operates in RGB internally, so the CMYK value I passed in was implicitly converted to RGB and converted back to CMYK in a second step. As a result the color values change.

I eventually came up with a simpler solution which gives me the desired result:

Code: Select all

convert -size 90x90 xc:"cmyk(255,255,18,97)" -colorspace CMYK -type ColorSeparation -depth 8 out.tif
I also have another case where two colors have to be shown side-by-side in the image. While that's straightforward with -draw, it took me some time to figure out an alternative. For reference here's the solution I came up with:

Code: Select all

convert -size 90x90 xc:"cmyk(255,255,18,97)" xc:"cmyk(0,0,0,100%)" -geometry "45x90\!+45+0" -composite -colorspace CMYK -type ColorSeparation -depth 8 out2.tif
Timo

Re: Problem generating CMYK color sample images

Posted: 2011-06-10T09:56:37-07:00
by fmw42
convert -size 90x90 xc:"cmyk(255,255,18,97)" xc:"cmyk(0,0,0,100%)" -geometry "45x90\!+45+0" -composite -colorspace CMYK -type ColorSeparation -depth 8 out2.tif
try

convert -size 90x90 xc:"cmyk(255,255,18,97)" xc:"cmyk(0,0,0,100%)" +append -colorspace CMYK -type ColorSeparation -depth 8 out2.tif

see
http://www.imagemagick.org/script/comma ... php#append
http://www.imagemagick.org/Usage/layers/#append

Re: Problem generating CMYK color sample images

Posted: 2011-06-10T13:03:16-07:00
by t.hoepfner
That's a great tip, thanks for that! It's amazing what IM can do when you find out how to tell it to it.

Regarding the original problem of -draw implicitly operating in RGB, I think it would be be a good idea to add a notice regarding that to the official docs.

Thanks again for the hint,

Timo