PHP & exec IM

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
chris2011
Posts: 5
Joined: 2011-06-20T00:47:22-07:00
Authentication code: 8675308

PHP & exec IM

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: PHP & exec IM

Post 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>";  
?> 
Post Reply