我想让Imagick工作,因为我想将PDF转换为图像。我可以成功打开其他文件,但无法打开PDF文件。
这会给我错误:无法读取文件
有人知道如何解决这个问题,或者如何找出问题所在?我尝试了其他PDF文件,但无法打开。
文件显然是可读的,并已通过(is_file)等进行了检查。一切正常,并且可以正常运行,但是Imagick无法打开PDF文件。
$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));
我尝试过:
$ imagick =新的Imagick('/ var / www / html / imagick / dummy.pdf'); $ imagick =新的Imagick('dummy.pdf');
但都给我一个错误:
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
当我使用try catch时,我得到了:
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] =>
)