问题
Since the ghostscript update 9.25 -> 9.26 (on debian) last morning we get this error:
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
When trying to read the first page of a multipage PDF:
$this->resource = new \Imagick();
$this->resource->setResolution(300, 300);
$this->resource->readImage($path . '[0]');
any idea how this problem can be solved?
See: https://www.ghostscript.com/doc/9.26/History9.htm#Version9.26 See: https://secure.php.net/manual/en/imagick.readimage.php
回答1:
Almost certainly this bug report:
https://bugs.ghostscript.com/show_bug.cgi?id=699815
Your solutions are; don't use the pngalpha device, don't use FirstPage/LastPage, upgrade to a version with the fix, or downgrade to an earlier version. Though that bug is potentially present in many earlier versions, I don't know why it hasn't exhibited before.
回答2:
I don't have "a solution" but can confirm the problem since upgrading to gs 9.26. I figured out, that, as KenS pointed out, everything works fine when removing the parameters -dFirstPage=1 -dLastPage=1 in gs.
What also works is to remove the gs-parameter -dMaxBitmap=500000000. Meaning in PHP, remove the [PAGE] i.e.:
$im = new \Imagick();
$im->readImage('/tmp/test.pdf');
My Working solution was a downgrade to ghostscript 9.22. I am using Ubuntu bionic LTS. Therefore I had to run:
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
回答3:
(Ghostscript 9.26) Had the same problem, after increasing setResolution(600, 600) started working again.
来源:https://stackoverflow.com/questions/53560755/ghostscript-9-26-update-breaks-imagick-readimage-for-multipage-pdf