duansaoguan7955 2016-10-20 06:32
浏览 192
已采纳

shell_exec,imagemagick将pdf转换为jpg返回错误

I use imagemagick convert PDF file to JPG , use PHP shell_exec('convert ./a.pdf ./a.jpg')

I get this error:

Error: /undefined in findresource Operand stack: --dict:15/24(L)-- F3 16.0 --dict:6/6(L)-- --dict:6/6(L)-- DroidSansFallback-UniGB-UTF16-H --dict:10/12(ro)(G)-- --nostringval-- CIDFontObject --dict:7/7(L)-- --dict:7/7(L)-- Adobe-GB1 Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop --nostringval-- --nostringval-- 2 1 1 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- false 1 %stopped_push --nostringval-- %loop_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %loop_continue Dictionary stack: --dict:1154/1684(ro)(G)-- --dict:1/20(G)-- --dict:75/200(L)-- --dict:75/200(L)-- --dict:106/127(ro)(G)-- --dict:286/300(ro)(G)-- --dict:22/25(L)-- --dict:4/6(L)-- --dict:26/40(L)-- Current allocation mode is local Last OS error: 2

Command in console is ok.

  • 写回答

1条回答 默认 最新

  • duangou6446 2016-10-20 08:54
    关注

    The answer is almost certainly related to the PATH - either to convert or ghostscript (which is required for the PDF aspect).

    Try the following, which doesn't require ghostscript:

    shell_exec('convert a.jp b.jpg');
    

    If that works, it's the PATH to ghostscript that is wrong.

    If it doesn't work, it is the PATH to convert which is wrong, or the script is not getting executed in the folder you think it is.

    As you state in the comments, the following actually solves the problem:

    putenv("PATH=/usr/local/bin");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法