php - 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
解决方案
我没有“解决方案”,但可以确认升级到 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
推荐阅读
- java - 如何使过滤器链线程本地化?
- android - ListView如何正确刷新?
- java - 手动实施 Oauth2 授权码授予流程
- asp.net - 使用 Asp.net core mvc 具有多搜索选项的搜索功能
- ubuntu - WSL 将 Bash 和 Ubuntu 应用程序分开,无法在我当前位于文件资源管理器中的目录中打开“Ubuntu”应用程序
- django - 尝试在模板“with”中分配变量,预计至少有一个变量分配
- c# - 用于控制用户可调整大小的 WPF 装饰器
- docker - 如何以简单的方式在不停机的情况下更换负载均衡器 Docker 容器
- entity-framework-core - _userManager.CheckPasswordAsync 在 net core 3.1 中抛出异常
- java - Problem running basic Spring Boot application