1
I am trying to convert a pdf into image using the Imagick library as follows:
<?
header('Content-type: image/jpeg');
$imagick = new Imagick();
// O myfile se encontra na mesma pasta do arquivo que estou executando
$imagick->readImage('myfile.pdf');
$imagick->writeImages('myfile.jpg', false);
I’m having the following mistake:
Fatal error: Uncaught Exception 'Imagickexception' with message 'Unable to read the file: Myfile.pdf' in /Users/myuser/teste.php:11 Stack trace: 0 /Users/myuser/test.php(11): Imagick->readimage('Myfile.pdf') 1 {main} thrown in /Users/myuser/teste.php on line 11
What could be?
Thanks for the reply, I made the above changes, I gave 777 permission to the file also to ensure, tested with is_readable() to make sure that the file can be read further has not worked yet.
– Daniel
Do you have Ghostscript (http://www.ghostscript.com/) installed? This may be a cause as well. Apparently, Imagick uses Gs to convert Pdfs.
– Lucas Lima
I installed using: Brew install php56-Imagick --with-Ghostscript I restarted apache too but nothing.
– Daniel