Page 1 of 1

All Colors Revert To Black When Composite Onto CMYK MIFF

Posted: 2011-10-24T00:04:25-07:00
by adfb
I'm quite familiar with ImageMagick and have been using it for a while. I use it to create book covers, they are CMYK 300dpi.

I used to use a combination of ImageMagick and the PHP IMagick functions, but then I decided to rewrite the script in only ImageMagick commands (called by PHP using exec) as I expect this will be more efficient.

The problem is that the colors disappear from the text when it is composited onto the canvas and they end up black!

See here:

Code: Select all

exec('convert -trim -background transparent -colorspace CMYK -font '.$spinetitlefont.' -size 930x'.ceil($spinewidth*0.75).' -fill "rgb(213,193,130)" caption:"'.$c_title.'" -rotate 90 output/'.$i9.'-working.png');
list($width, $height, $type, $attr)=getimagesize('output/'.$i9.'-working.png'); $w=2700-($width/2);
exec('composite -compose Over -geometry +'.$w.'+994 output/'.$i9.'-working.png output/'.$i9.'-cover.miff output/'.$i9.'-cover.miff');
The resulting text is not "rgb(213,193,130)" as it should be, but black. It is the correct color in the working.png file where the text is created, but loses its color when composited onto the canvas (miff file, CMYK, 300dpi).

The same happens whether or not I set "-colorspace CMYK" for the text.

Please help!

Re: All Colors Revert To Black When Composite Onto CMYK MIFF

Posted: 2011-10-24T06:00:33-07:00
by adfb
Figured out the solution myself:

It works if you convert to tiff (or miff, but I had to use tiff because I was checking the width & height from PHP and miff is not supported for this) and colorspace to CMYK first, then composite onto the CMYK miff canvas.

Re: All Colors Revert To Black When Composite Onto CMYK MIFF

Posted: 2011-10-24T22:56:37-07:00
by anthony
The first part of MIFF: file format is plain ascii text! It should be very easilly parsible by PHP with a little coding, and in fact should be faster than having something read in the whole TIFF just to get image size!

In fact it is pretty well always the third line of the file! you can abort reading the file as soon as you have it!

See MIFF special file format for details....
http://www.imagemagick.org/Usage/files/#miff