Page 1 of 1

wrong cmyk color with annotateImage.

Posted: 2014-01-30T02:45:36-07:00
by erwan
Hi, i'm trying to write text on a jpeg-cmyk image, everything works correctly but the color of the text.
For example, if I set a color with setColor("cmyk(0,0,0,0)") it should appear as white but it appear grey/black :?
I'm using the Imagick class on PHP.
any idea ?

my code:

Code: Select all

	$imgname="CMYK300dpi.jpg";
	$font = 'Arial Bold.ttf'; //download ici http://4nts.com/component/ttf/?sel=flypage&id=351
	$text = "0899 123 457";

	$image = new Imagick($imgname);
	$draw = new ImagickDraw();
	$pixel= new ImagickPixel();
	if(!$pixel->setColor("cmyk(0,0,0,0)"))
		echo "Erreur lors du setColor\n";
	$draw->setFillColor($pixel);
	$draw->setFont($font);
	$draw->setFontSize( 30 );
	$image->annotateImage($draw, 32, 165, 0, $text);
	file_put_contents("CMYK300dpi_txt.jpg",$image);

Re: wrong cmyk color with annotateImage.

Posted: 2014-01-30T10:49:50-07:00
by fmw42
I am not an expert on this, but I believe that adding color text only works correctly in RGB images. So you would have to convert your image to sRGB, add the text, and then if you really want, convert back to CMYK.

You could try specifying the text colors as RGB, but I suspect that will really not help.

I will defer to any one who has more expertise on this.