CentOS7下Imagick读取PDF报Postscript delegate失败求助
环境
- CentOS 7
- Apache
- PHP 7.4
测试代码
$ofile = 'test.pdf'; $imagick = new Imagick(); $imagick->readImage($ofile);
执行报错信息
Fatal error: Uncaught ImagickException: Postscript delegate failed `[ghostscript library 9.25] -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=/tmp/magick-16528HfVzp_FNGdCX%d' '-f/tmp/magick-16528LrkMb-C0CmIS' '-f/tmp/magick-165281qaTU7bnOBON'': ./base/gsicc_manage.c:1244: gsicc_open_search(): Could not find default_gray.icc | ./base/gsicc_manage.c:2261: gsicc_init_iccmanager(): cannot find default icc profile ./base/gsicc_manage.c:1244: gsicc_open_search(): Could not find default_rgb.icc | ./base/gsicc_manage.c:2025: gsicc_set_device_profile(): cannot find device profile **** Unable to open the initial device, quitting. @ error/ghostscript-private.h/InvokeGhostscriptDelegate/171
已尝试的无效方案
- 重装Imagick扩展
- 手动添加环境变量:
putenv('PATH=' . getenv('PATH') . ':/usr/share/ghostscript/lib:/usr/share/ghostscript/iccprofiles:/usr/share/ghostscript/Resource/Init/');
解决方案
已解决!问题根源是PHP Jail限制了GhostScript访问ICC配置文件的路径权限,解除对应路径的访问限制后,Imagick即可正常读取PDF文件。
内容的提问来源于stack exchange,提问作者uana

