Problem generating CMYK color sample images

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?".
Post Reply
t.hoepfner
Posts: 18
Joined: 2006-12-18T14:41:21-07:00

Problem generating CMYK color sample images

Post 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
t.hoepfner
Posts: 18
Joined: 2006-12-18T14:41:21-07:00

Re: Problem generating CMYK color sample images

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem generating CMYK color sample images

Post 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
t.hoepfner
Posts: 18
Joined: 2006-12-18T14:41:21-07:00

Re: Problem generating CMYK color sample images

Post 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
Post Reply