【发布时间】:2021-05-01 08:01:16
【问题描述】:
我已经在 Windows Server 2016 Standard 上安装了 ImageMagick-7.0.10-Q16-HDRI 和 gs9.53.3。
这个sn-p:
$pages = [];
$im = new \Imagick();
$im->setresolution(150, 150);
$im->readimage("/test.pdf");
for ($i = 0; $i < $im->getnumberimages(); $i++) {
$im->setiteratorindex($i);
$im->setimageformat('jpg');
$im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE);
array_push($pages, addslashes($im->getimageblob()));
}
$im->destroy();
结果:
Fatal error: Uncaught ImagickException: PDFDelegateFailed `The system cannot find the file specified. ' @ error/pdf.c/ReadPDFImage/794 in .........\dev\gs_test.php:11 Stack trace: #0 E:\inetpub\wwwroot\test-analysis\dev\gs_test.php(11): Imagick->readimage() #1 {main} thrown in .......\dev\gs_test.php on line 11
我尝试将 gs4win64c.exe 复制到 gs.exe 并将C:\Program Files\gs\gs9.53.3\bin 添加到 PATH,现在得到:
Fatal error: Uncaught ImagickException: PDFDelegateFailed `Error: /undefinedfilename in (C:/Windows/TEMP/magick-8156OUt95Ei0WCah) Operand stack: Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push Dictionary stack: --dict:737/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)-- Current allocation mode is local Last OS error: Permission denied GPL Ghostscript 9.53.3: Unrecoverable error, exit code 1 ' @ error/pdf.c/ReadPDFImage/794 in .......\dev\gs_test.php:11 Stack trace: #0 ........\dev\gs_test.php(11): Imagick->readimage() #1 {main} thrown in .......\dev\gs_test.php on line 11
我对现在发生的事情有点困惑!完全相同的代码在我的测试 Unix 服务器上开箱即用。
【问题讨论】:
-
我认为这可能是版本不兼容造成的。尝试更改 Ghostscript 的版本,将 Ghostscript 9.53.3 更改为 32 位。
-
谢谢,但不幸的是我都安装了,我还尝试将 gs4win32c.exe 作为 gs.exe 放入,结果相同:)
标签: php windows iis ghostscript imagick