I need to execute ImageMagick's convert
via shell_exec
in a php file running apache as localhost on a mac running snow leopard. I have tried all sorts of tips, tricks, edits and permissions garnered from a multitude of questions and solutions from here. But nothing seems to do the trick. The php file below highlights the problem:
<?php
echo shell_exec('whoami'); //daemon. I chown-ed convert by daemon
apache_setenv('PATH', '/usr/local/bin:/usr/bin:/bin'); // this works: checked with getenv("PATH");
echo shell_exec('cp /Users/fullpath/file.pdf /Users/fullpath/file.pdf 2>&1'); // this works, so shell_exec works
echo shell_exec('/usr/local/bin/convert /Users/fullpath/file.pdf /Users/fullpath/file.png 2>&1'); // this fails, convert: UnableToCreateTemporaryFile and then convert: NoImagesDefined
?>
I assume this is a permissions problem: but where, on which file?
EDIT: The full error message is:
convert: UnableToCreateTemporaryFile `/Users/fullpath/file.pdf': Permission denied @ error/pdf.c/ReadPDFImage/390.
convert: NoImagesDefined `/Users/fullpath/file.png' @ error/convert.c/ConvertImageCommand/3021.
You are executing convert
successfuly, but then the convert
itself is returning the error convert: UnableToCreateTemporaryFile and then convert: NoImagesDefined
.
I think this is the answer to the underlying question can be found at https://superuser.com/questions/819277/cant-convert-pdf-into-image-because-of-no-images-defined-error
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.