Page 1 of 1

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

Posted: 2007-03-05T17:35:57-07:00
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?

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

Posted: 2007-03-05T20:15:12-07:00
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.

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

Posted: 2007-03-06T12:56:28-07:00
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");