自昨晚 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
几乎可以肯定这个错误报告:
https://bugs.ghostscript.com/show_bug.cgi?id=699815
您的解决方案是;不要使用 pngalpha 设备,不要使用 FirstPage/LastPage,升级到已修复的版本,或降级到早期版本。虽然这个错误可能存在于许多早期版本中,但我不知道为什么它以前没有出现过。
我没有“解决方案”,但可以确认升级到 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
(Ghostscript 9.26) 有同样的问题,增加 setResolution(600, 600) 后再次开始工作。
2023:在 Ghostcript bin 文件夹中,我复制了 gswin64c 并将副本重命名为 gs.exe。为我工作