I am using PHP’s exec() to convert an image using ImagicMagick’s convert. This is being run on a CentOS server.
exec(convert http://www.google.com/images/srpr/logo3w.png.jpg
-resize 640 /home/mysite/public_html/public/img/posts/original/1414_301a4.jpg);
Using exec() does not cause the new image to appear in the destination folder. However if I were to run the same command in the shell, it works perfectly!
I believe this is a PATH problem. If so, how can I check the path that PHP is using, and how can I set the correct path in PHP?
First, you should try with an input file that does indeed exist and is retrievable:
Then, to see which
convertyour PHP uses:and
Last, also try with the full path to
convert:and then
Update:
The file that you meant to retrieve was probably not
logo3w.png.jpg, butlogo3w.png:Also, in case it works for local files only (not remote http-URIs) you may need to check if the http delegate used by
convertis indeed installed on your system:Plus, check if the user account your PHP runs under does indeed have the right to write to the target directory:
and then