dongsu3138 2014-11-27 09:34
浏览 90
已采纳

Mac Yosemite上的PHP上的Ghostscript不起作用。 在Shell上它起作用

I 'm despair...

I installed Ghostscript on Mac OS X Yosemite via Homebrew. Ghostscript works well over the shell, but it doesn't work, if it is executed via PHP.

$gs = '/usr/local/opt/ghostscript/bin/gs';

// Count PDF
$shell = $gs . ' -q    -dNODISPLAY    -c "(' . $pdf . ') (r) file runpdfbegin pdfpagecount = quit" 2>&1';
$result =  shell_exec($shell);

// Execution
$shell = $gs . ' -dNumRenderingThreads=4 -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -sOutputFile="' . $filePathThumb . '" -dJPEGQ=100 -r300 -q "' . $pdf . '" -c quit 2>&1';
$result =  shell_exec($shell);

The output of $result is:

dyld: Library not loaded: /usr/local/lib/libtiff.5.dylib
Referenced from: /usr/local/opt/ghostscript/bin/gs
Reason: Incompatible library version: gs requires version 8.0.0 or later, but libtiff.5.dylib      provides version 7.0.0

If i execute the same command on the shell it works...

I tired so many things in the last days, but i still struggling.

I reinstalled gs and imagemagick, i removed the symlinks, runned brew doctor, tried some other libtiff.5.dyslib files.

My environment:

  • Yosemite
  • PHP Version 5.5.13
  • Zend Server Version: 7.0.0
  • Imagemagick Version 6.8.9-8 (installed via brew)
  • Ghostscript Version 9.15 (installed via brew)
  • 写回答

1条回答 默认 最新

  • dongpeixiong5943 2014-11-27 13:28
    关注

    Clearly you are using a version of Ghostscript with shared libraries (which is why it wants libtiff.dylib). We don't recommend that, and you could avoid it by downloading the Ghostscript sources and building them yourself. This is a 'some assembly required' project, as you will need things like gcc installed. However I managed it and I'm far from a Mac expert.

    However, this will probably just move you on the real underlying problem which is that your PHP environment does not match your shell. In this case the PATH environment variable is probably different, which means that the shell can find the dynamic library, but the PHP can't.

    Since Ghostscript can use certain environment variables, you need to make sure that the environment that the PHP script executes in is the same as the one the shell uses.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行