dongyanju1094 2019-03-23 20:36
浏览 346

Imagick无法读取文件(pdf)但能够读取图像

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] => 
)
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试