Page 1 of 1

PHP & exec IM

Posted: 2013-01-13T04:37:00-07:00
by chris2011
Hi there,

when running this from the commandline:

../../image/ImageMagick-6.7.1-0/utilities/convert -type palette -depth 8 -strip -quality 85 ../photos/picture_temp_12000.jpg -background white -resize 4000x3000 -background white -compose Copy -gravity center -extent 4500x3000 -gravity NorthWest -crop 1140x760+360+1030 -resize 450x300\! ../npicn/p2000d.jpg

everything is fine. When running this via PHP (even everything from the correct dir)

<?
$r=system("../../image/ImageMagick-6.7.1-0/utilities/convert -type palette -depth 8 -strip -quality 85 ../photos/picture_temp_12000.jpg -background white -resize 4000x3000 -background white -compose Copy -gravity center -extent 4500x3000 -gravity NorthWest -crop 1140x760+360+1030 -resize 450x300\! ../npicn/p2000d.jpg");
echo $r;
?>

nothing happens and it returns immediately to the php script. The image is not converted. Using other images everythings works fine.

Running on a Linux with apache ...

What can I do to find the problem?

Regards
Chris

Re: PHP & exec IM

Posted: 2013-01-13T08:30:17-07:00
by Bonzo
You command looks a bit of a mess; you are resizing three times and have -background twice. :?

You should read the image in first and I would have thought you could just get away with convert not the path to convert although I know nothing about Linux.

System is used more for displaying output where as exec is not.

Try:

Code: Select all

<?
// Error reporting added
$array=array(); 
echo "<pre>";
exec("convert -type palette ../photos/picture_temp_12000.jpg -depth 8 -strip -resize 4000x3000 -background white -gravity center -extent 4500x3000 -gravity NorthWest -crop 1140x760+360+1030 -resize 450x300\! -quality 85 ../npicn/p2000d.jpg 2>&1", $array);  
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";  
?>