permission problems with PHP and imagemagic

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
josh4

permission problems with PHP and imagemagic

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: permission problems with PHP and imagemagic

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

Re: permission problems with PHP and imagemagic

Post 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.
josh4

Re: permission problems with PHP and imagemagic

Post 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
Post Reply