Convert & Color Profiles: Command line, Yes. PHP Exec, No.

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
RXGX

Convert & Color Profiles: Command line, Yes. PHP Exec, No.

Post by RXGX »

CentOS 4, Apache 2.0.53, PHP 4, IM6.3.2 Q16

The following code successfully converts a CMYK PDF to a RGB TIF/JPG when entered in command line:

Code: Select all

convert {$name}.pdf -profile cmyk.icc -profile srgb.icm -density 300 -resample 72x72 -units PixelsPerInch {$name}.tif
However, when I call the exact same command within an EXEC() function, the color profile is destroyed. Firefox says there are errors and Photoshop says ICC profile is invalid. Anyone know what I am doing wrong or know how I could find out what Apache is doing?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Convert & Color Profiles: Command line, Yes. PHP Exec, No.

Post by anthony »

Add a 'set -x;' before the convert command and see what the UNIX shell is seeing
for exection. Not that returns TEXT, so make sure you PHP is swiched to see that text output.

For more look for some PHP debuging web pages. There should be hundreds of them for exec() problems.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
RXGX

Re: Convert & Color Profiles: Command line, Yes. PHP Exec, No.

Post by RXGX »

The "set -x;" didn't work, but adding "2>&1" at the end of my command did.

Code: Select all

exec("convert {$name}.pdf -profile cmyk.icc -profile srgb.icm -density 300 -resample 72x72 -units PixelsPerInch {$name}.tif 2>&1", $array);
echo implode($array,"<br>");
I found out that it was using IM6.0.x RPM instead of my custom build (6.3.2) with LCMS. The updated and working code is:

Code: Select all

exec("/usr/local/bin/convert -density 300 -units PixelsPerInch -profile cmyk.icc -profile srgb.icm {$name}.pdf -resample 72x72 {$name}.tif");
Post Reply