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 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄