wrong cmyk color with annotateImage.

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
erwan
Posts: 1
Joined: 2014-01-30T02:28:47-07:00
Authentication code: 6789

wrong cmyk color with annotateImage.

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

Re: wrong cmyk color with annotateImage.

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