簡體   English   中英

PHP Ghostscript錯誤,但命令行工作正常(將pdf解碼為png)

[英]PHP Ghostscript error, but command line works fine (decoding pdf to png)

我正在從命令行執行以下命令:

gs -sOutputFile=- -sDEVICE=pnggray -dFirstPage=1 -dLastPage=1 -dNOPAUSE -sPAPERSIZE=a4 -r90 -q /Volumes/DATA/03-www/temp/test.pdf -c quit

它工作正常,將pdf解碼為png。 但是然后我從php執行以下代碼:

$cmd = "gs -sOutputFile=- -sDEVICE=pnggray -dFirstPage=1 -dLastPage=1 -dNOPAUSE -sPAPERSIZE=a4 -r90 -q " . $pdf_file . " -c quit";
$img = shell_exec($cmd);

我得到空響應。 我在$ cmd后面附加了2>&1以查看錯誤:

$cmd = "gs -sOutputFile=- -sDEVICE=pnggray -dFirstPage=1 -dLastPage=1 -dNOPAUSE -sPAPERSIZE=a4 -r90 -q " . $pdf_file . " -c quit 2>&1";

輸出為以下內容:

dyld: Library not loaded: /opt/local/lib/libtiff.5.dylib
  Referenced from: /opt/local/lib/libgs.9.16.dylib
  Reason: Incompatible library version: libgs.9.16.dylib requires version 8.0.0 or later, but libtiff.5.dylib provides version 6.0.0

Ghostscript版本給出(cli):

GPL Ghostscript 9.16 (2015-03-30)
Copyright (C) 2015 Artifex Software, Inc.  All rights reserved.

有什么幫助嗎?

在我看來,您正在使用使用共享庫的Ghostscript構建,而系統找不到libtiff 8動態庫。

您似乎已經安裝了libtiff 5,但您需要libtiff8。大概是為您的用戶安裝了libtiff 8,但沒有為PHP用戶安裝,這就是為什么它可以從命令行使用的原因。

或者,您可以使用不使用共享庫的Ghostscript構建,但這將意味着您自己構建它,因為您發行版的打包程序似乎選擇了使用共享庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM