CMYK Pixel Color Set Issue

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
aenglander

CMYK Pixel Color Set Issue

Post by aenglander »

ImageMagick Version: ImageMagick 6.3.3 04/21/07 Q16 (Win32 on Vista x64)
imagick module version 2.0.0-rc1
PHP Version 5.2.4

I have run into a few issues attempting to annotate an 8-bit TIFF file. UsingImageMagick 6.3.6 Q16 with and without imagick. I was never able to get CMYK color values i.e. "cmyk(100%,0,0,100)" for cyan. It interprets the fist three items and uses them in an RGB type color scheme. Instead of cmyk(100%,0,0,0) being cyan, it show up as a true red as would be expected in rgb(255,0,0) represented as C:0%,Y:100%,M:100%,K0%

Code Below:

Command Line:
convert base-business-card.tif -font arial -pointsize 52 -fill cmyk(255,0,0,0) -draw "text 200 200 'This is a test'" new.tif

PHP Code:
$fontdir = getcwd().'/fonts';
$imgdir = getcwd().'/images';

$imagick = new Imagick($imgdir.'/base-business-card.tif');
$imagickDraw = new ImagickDraw();
$imagickPixel = new ImagickPixel();
$imagick->setImageColorspace(Imagick::COLORSPACE_CMYK);
$imagickPixel->setColor('cmyk(100%,0,0,0'));
$imagickDraw->setFillColor($imagickPixel);
$imagickDraw->setStrokeColor($imagickPixel);
$imagickDraw->setFont($fontdir.'/arial.ttf');
$imagickDraw->setFontSize(52);
$imagick->annotateImage($imagickDraw,200,200,0,'This is a test');

header( "Content-type: " . $imagick->getImageType() );
print $imagick->getImageBlob();
Attachments
base-business-card.zip
File used in code sample zipped for compression
(8.19 KiB) Downloaded 1200 times
MarcinG

Re: CMYK Pixel Color Set Issue

Post by MarcinG »

Im having the same issue, red is blue, blue is orange..this sucks :)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: CMYK Pixel Color Set Issue

Post by magick »

Drawing and text annotation requires the RGB color model. Convert your CMYK image to RGB, annotate it, and then convert it back from RGB to CMYK.
Post Reply