0

I'm using the following code

  $imagick = new Imagick();
// Reads image from PDF
$imagick->readImage('sample.pdf');
// Writes an image or image sequence Example- converted-0.jpg, converted-1.jpg
$imagick->writeImages('converted.jpg', false);

Fatal error: Uncaught exception 'ImagickException' with message 'UnableToOpenBlob `sample.pdf': No such file or directory @ error/blob.c/OpenBlob/2702' in D:\xampp\htdocs\full_delay\fulcrum\www\www.axis.com\app\imagick\imagick-test.php:15 Stack trace: #0 D:\xampp\htdocs\full_delay\fulcrum\www\www.axis.com\app\imagick\imagick-test.php(15): Imagick->readimage('sample.pdf') #1 {main} thrown in D:\xampp\htdocs\full_delay\fulcrum\www\www.axis.com\app\imagick\imagick-test.php on line 15

Kampai
  • 22,848
  • 21
  • 95
  • 95

1 Answers1

1

You should provide fullpath of your file. Like error said, there is no file sample.pdf in the directory where your code is executed.

Set a path like this:

$imagick = new Imagick();
// Reads image from PDF
$imagick->readImage('D:\xampp\htdocs\full_delay\fulcrum\www\www.axis.com\app\imagick\sample.pdf');
// Writes an image or image sequence Example- converted-0.jpg, converted-1.jpg
$imagick->writeImages('converted.jpg', false);

Where D:\xampp\htdocs\full_delay\fulcrum\www\www.axis.com\app\imagick\sample.pdf is the path of your file.

ManUtopiK
  • 4,495
  • 3
  • 38
  • 52
  • My error got cleared , but I did't got any output. the browser says "The connection was reset" – suganthi devi Aug 27 '19 at 11:46
  • I haven't used Imagick since a while. I think your code is incomplete. Take a look on this question: https://stackoverflow.com/questions/9227014/convert-pdf-to-jpeg-with-php-and-imagemagick or the manual: https://www.php.net/manual/en/book.imagick.php – ManUtopiK Aug 27 '19 at 11:52