CMYK Color Issue w/TIFF Text Draw

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 Color Issue w/TIFF Text Draw

Post by aenglander »

Sorry for the cross post but it occurs in both command line and PHP Imagick

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%. The test starting file is attached to the PHP post.

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();
Post Reply