I am trying to get Imagick to work because I want to convert PDF to images. I can succesfully open other files but I am unable to open PDF files.
It will give me the error: Failed to read the file
Does anyone know how to solve this and -or how to find out what the problem is? I tried different PDF files but none were able to be opened.
- Ubuntu 18.04
- Lumen (newest version)
File is obviously readable and checked with (is_file) et cetera. Everything is fine and working but only PDF files are unable to be opened by Imagick.
$imagick = new \Imagick();
$imagick->readImage('/var/www/html/mysite.com/storage/app/files/dummy.pdf');
$imagick->writeImages('/var/www/html/mysite.com/storage/app/files/converted.pdf', false));
I tried:
$imagick = new Imagick('/var/www/html/imagick/dummy.pdf'); $imagick = new Imagick('dummy.pdf');
but both give me an error:
Fatal error: Uncaught ImagickException: Failed to read the file in /var/www/html/imagick/index.php:33 Stack trace: #0 /var/www/html/imagick/index.php(33): Imagick->__construct('dummy.pdf') #1 {main} thrown in /var/www/html/imagick/index.php on line 33
When I use a try catch I get this:
ImagickException Object
(
[message:protected] => Failed to read the file
[string:Exception:private] =>
[code:protected] => 1
[file:protected] => /var/www/html/imagick/index.php
[line:protected] => 13
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /var/www/html/imagick/index.php
[line] => 13
[function] => __construct
[class] => Imagick
[type] => ->
[args] => Array
(
[0] => /var/www/html/imagick/dummy.pdf
)
)
)
[previous:Exception:private] =>
)