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.

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

报告相同问题?

悬赏问题

  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题