Page 1 of 1

permission problems with PHP and imagemagic

Posted: 2009-08-12T13:17:15-07:00
by josh4
I'm running a shell command through a PHP script.

convert -rotate +0 -background transparent "/var/www/html/uploadfiles/1250077554_66_927STEM-115.jpg" /var/www/html/temp/source1.png

I try this command line and it works. But source1.png isn't created when this is run through PHP. All the files and folders exist and have full write permissions. PHP has been tested and is able to create other files, just not files through command line with imagemagick.

Any help appreciated.

Re: permission problems with PHP and imagemagic

Posted: 2009-08-12T13:38:53-07:00
by fmw42
you do not show your PHP command. note that you likely need to provide the full path to convert, usually /usr/local/bin/convert

Re: permission problems with PHP and imagemagic

Posted: 2009-08-12T14:31:10-07:00
by Bonzo
You want to read the image in first; you do not need full paths to the folders etc. relative ones will do.

Try with this error reporting:

Code: Select all

<?php
$array=array();
echo "<pre>"
exec("convert /var/www/html/uploadfiles/1250077554_66_927STEM-115.jpg -background transparent -rotate +0 /var/www/html/temp/source1.png 2>&1", $array); 
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
?> 
There could be a path problem or as Fred says you may need to give the path to convert; find that with this code:

Code: Select all

<?php
echo "<pre>";
system("type convert"); 
echo "</pre>";
?>
This should be posted in the users section.

Re: permission problems with PHP and imagemagic

Posted: 2009-08-14T18:09:37-07:00
by josh4
So the apache error logs showed that when run from PHP it wasn't finding imagemagick. "command not found"

Changing the commands to use the full path fixed the problem. /usr/local/blah/blah/convert