I installed the ImageMagick PHP extension on MAC through pecl. it is displayed in phpinfo () and lists the PDF as a supported format.
I am trying to read a PDF file and convert it to an image. However, the constructor throws an exception when the source is PDF. Image files work successfully.
$im = new imagick('TestDoc.pdf[0]');
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;
Fatal error: Uncaught exception 'ImagickException' with message 'FailedToExecuteCommand
`"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -
dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4
"-r72x72" -dFirstPage=1 -dLastPage=1 "-sOutputFile=/var/tmp/magick-43594XlaRxeGWg1ps%d" "-
f/var/tmp/magick-43594O_WVqnAJTgzr" "-f/var/tmp/magick-43594ivJ_pKBcF3s7"' (-1) @
error/utility.c/SystemCommand/2029' in
/Users/garys/Documents/Projects/accrivia/code/test/test.php:8 Stack trace: #0
/Users/garys/Documents/Projects/accrivia/code/test/test.php(8): Imagick-
>__construct('../TestDoc.pdf[...') #1 {main} thrown in
/Users/garys/Documents/Projects/accrivia/code/test/test.php on line 8
This creates the tmp file specified in the output, but is 0 bytes. If I execute the full gs command in the message (using the actual files) on the command line, it works successfully.
ImageMagick and GhostScript were installed using brew.
In PHP, the system ('echo $ PATH'); gives / usr / bin: / bin: / usr / sbin: / sbin 'gs' is located in / usr / bin /
- . - .
.