Error in readImage using Imagick ()

1

I'm 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 error:

  

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/teste.php(11): Imagick-> readimage ('myfile.pdf')   1 {main} thrown in /Users/myuser/teste.php on line 11

What could it be?

    
asked by anonymous 11.11.2014 / 12:09

1 answer

1

Try the full directory for the image:

$image->readImage($_SERVER['DOCUMENT_ROOT'] . '/dir_da_imagem/myfile.pdf');
$imagick->writeImages($_SERVER['DOCUMENT_ROOT'] . '/dir_da_imagem/myfile.jpg', false);

Where image_dir is the relative directory of myfile.pdf . Otherwise, check the permissions of myfile.pdf and if the file is not corrupted.

    
11.11.2014 / 12:24