簡體   English   中英

未捕獲的異常'ImagickException',消息'無法讀取文件'

[英]Uncaught exception 'ImagickException' with message 'Failed to read the file'

我在使用Imagick讀取文件時遇到問題。 我成功安裝了imagick和ghostscript擴展。

這就是我正在做的事情:

<?php

    $im = new Imagick();
    $im->setResolution(300, 300);
    $im->readImage('/Applications/MAMP/htdocs/mywebsite/wp-content/plugins/myplugin/uploads/magazine_cover.pdf[0]');
    $im->setImageFormat('jpg');
    header('Content-Type: image/jpeg');
    echo $im;

?>

我收到錯誤:

致命錯誤:第10行/Applications/MAMP/htdocs/imagick.php中未捕獲的異常'ImagickException',消息'無法讀取文件'

當我嘗試在終端中執行以下命令時:

convert magazine_cover.pdf magazine_cover.jpeg

我收到警告:

**** Warning: considering '0000000000 XXXXX n' as a free entry.

**** This file had errors that were repaired or ignored.
**** The file was produced by:
**** >>>> Mac OS X 10.11.3 Quartz PDFContext <<<<
**** Please notify the author of the software that produced this
**** file that it does not conform to Adobe's published PDF
**** specification.

但他創造了jpeg ...... 為什么這不適用於瀏覽器?

那么警告是由Ghostscript生成的,它說你的PDF文件在技術上不合法,但它應該處理得很好,除非有更多的問題。

我建議你找出ImageMagick傳遞給Ghostscript的命令,並在命令行上嘗試。 如果它工作,那么問題最有可能在IM結束,否則問題是Ghostscript不喜歡你的PDF文件。 命令行可能會為您提供更多信息。 即使它沒有該信息和文件,您也可以打開Ghostscript錯誤報告,並且可以修復(如果可能)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM