All Colors Revert To Black When Composite Onto CMYK MIFF

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
adfb
Posts: 2
Joined: 2011-10-22T10:43:08-07:00
Authentication code: 8675308

All Colors Revert To Black When Composite Onto CMYK MIFF

Post 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!
adfb
Posts: 2
Joined: 2011-10-22T10:43:08-07:00
Authentication code: 8675308

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

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply