You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS7下Imagick读取PDF报Postscript delegate失败求助

解决Imagick读取PDF时GhostScript ICC配置文件缺失报错问题

环境

  • 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 19:43:23