首页 > 解决方案 > ghostscript 9.26 更新打破了多页 PDF 的 imagick readImage

问题描述

自从 Ghostscript 更新 9.25 -> 9.26(在 debian 上)昨天早上我们得到这个错误:

ErrorMessage: FailedToExecuteCommand 
`'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT
 -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 
'-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r300x300' 
-dFirstPage=1 -dLastPage=1 '-sOutputFile=/tmp/magick-39903EapVvuyNQxL4%d' 
'-f/tmp/magick-39903VD0GMIpLPaIN' 
'-f/tmp/magick-399031owlSOb4aOEw'' (-1) 
@ error/delegate.c/ExternalDelegateCommand/462

尝试阅读多页 PDF 的第一页时:

$this->resource = new \Imagick();
$this->resource->setResolution(300, 300);
$this->resource->readImage($path . '[0]');

知道如何解决这个问题吗?

见:https ://www.ghostscript.com/doc/9.26/History9.htm#Version9.26 见:https ://secure.php.net/manual/en/imagick.readimage.php

标签: phpghostscriptimagick

解决方案


我没有“解决方案”,但可以确认升级到 gs 9.26 后的问题。我发现,正如 KenS 指出的那样,在 gs 中删除参数 -dFirstPage=1 -dLastPage=1 时一切正常。

同样有效的是删除 gs 参数 -dMaxBitmap=500000000。在 PHP 中的含义,删除 [PAGE] 即:

$im = new \Imagick();
$im->readImage('/tmp/test.pdf');

我的工作解决方案是降级到 ghostscript 9.22。我正在使用 Ubuntu 仿生 LTS。因此我不得不运行:

sudo apt-get remove ghostscript
sudo apt-get autoremove
sudo apt-get install ghostscript=9.22~dfsg+1-0ubuntu1 libgs9=9.22~dfsg+1-0ubuntu1 libgs9-common=9.22~dfsg+1-0ubuntu1
sudo apt-mark auto libgs9
sudo apt-mark auto libgs9-common

推荐阅读