【问题标题】:PHP Imagick - Postscript delegate failed: No such file or directoryPHP Imagick - Postscript 委托失败:没有这样的文件或目录
【发布时间】:2019-04-17 12:09:10
【问题描述】:

我对 PHP 的 imagick 有疑问。

我的环境:

  • Ubuntu 14.04
  • PHP 5.5.9 (1ubuntu4.26)
    • 通过 pecl 安装了 imagick
  • Apache 2.4.7
  • ImageMagick 6.7.7-10 2018-09-28 Q16
  • Ghostscript 9.25

显示 phpinfo() 告诉我一切都很好 - imagemagick 被识别并且 pdf 以支持的格式列出。

在 PHP 中我做了以下操作:

//$pdfAbsolutePath is /path/to/MF-NEU-22306.pdf[0]
$im = new \Imagick($pdfAbsolutePath);

此时我收到以下错误:

Postscript delegate failed `/path/to/MF-NEU-22306.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/677
[app/controller/web/fax.php:1028] Imagick->readimage('/path/to/MF-NEU-22306.pdf[0]')

文件存在于指定路径。

我做错了什么?从命令行手动调用convert 运行完美,与从命令行运行gs 相同。在phpinfo() 的输出中,为使用和 ImageMagick 库编译的 imagick 提供的版本是相同的。我还尝试完全卸载 ImageMagick 和 ghostscript 并重新安装它——无论是从 apt-get 还是从源代码编译,但没有任何效果。

我该如何解决这个问题?任何帮助表示赞赏。

编辑:

delegates.xml/etc/ImageMagick/ 中的这两行是 pdf 代表:

<delegate decode="pdf" encode="eps" mode="bi" command="&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=nodevice&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;"/>
<delegate decode="pdf" encode="ps" mode="bi" command="&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=nodevice&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;"/>

编辑 2:

我现在尝试了一种“解决方法”——不是在方括号中指定页码,而是在遍历页面时使用$im-&gt;setIteratorIndex($i)。到目前为止它有效,但现在我有另一个例外:

WriteBlob Failed `/path/to/1-607405443.png' @ error/png.c/MagickPNGErrorHandler/1726
[app/controller/web/fax.php:1044] Imagick->writeimage('/path/to/1-607405443.png')

我现在做错了什么?

【问题讨论】:

  • 很可能Ghostscritp 可执行文件不在您的PHP“用户”的$PATH 中,因此无法找到执行它。看到这个问题,例如stackoverflow.com/questions/10455985/…
  • 尝试查看您的delegates.xml 文件,并可能在PDF 委托下添加gs 的完整路径。
  • 不知道你应该如何找到delegates.xml,但这是有效的convert -debug all xc:black info: 2&gt;&amp;1 | grep "Loading delegate"
  • @KenS:我找到了这个答案,但我的 gs 已经位于 /usr/bin/ 下。
  • @MarkSetchell 运行你的命令convert -debug all... 什么也没显示。在没有 grep 的情况下运行它会显示很多,但正如预期的那样,没有“正在加载代表”。 /etc/ImageMagick/ 中有一个 delegates.xml - 你可以在我最初的帖子中看到 pdf 的代表(评论太长了)。

标签: php pdf imagemagick ghostscript imagick


【解决方案1】:

我的错是服务器上缺少 tesseract 安装...也许这会对某人有所帮助。

【讨论】:

    猜你喜欢
    • 2012-05-14
    • 2014-01-24
    • 1970-01-01
    • 2013-01-13
    • 2021-05-13
    • 1970-01-01
    • 2018-03-26
    • 2021-12-27
    • 1970-01-01
    相关资源
    最近更新 更多