Gar*_*ary 5 php pdf imagemagick ghostscript
我已经通过pecl在MAC上安装了ImageMagick PHP扩展.它出现在phpinfo()下,并将PDF列为支持的格式.
我正在尝试阅读PDF并将其转换为图像.但是,当源是PDF时,构造函数会引发异常.图像文件成功运行.
$im = new imagick('TestDoc.pdf[0]'); // Throws Exception when PDF specified.
//$im = new imagick('TestImage.png'); // Succeeds.
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;
Fatal error: Uncaught exception 'ImagickException' with message 'FailedToExecuteCommand
`"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -
dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4
"-r72x72" -dFirstPage=1 -dLastPage=1 "-sOutputFile=/var/tmp/magick-43594XlaRxeGWg1ps%d" "-
f/var/tmp/magick-43594O_WVqnAJTgzr" "-f/var/tmp/magick-43594ivJ_pKBcF3s7"' (-1) @
error/utility.c/SystemCommand/2029' in
/Users/garys/Documents/Projects/accrivia/code/test/test.php:8 Stack trace: #0
/Users/garys/Documents/Projects/accrivia/code/test/test.php(8): Imagick-
>__construct('../TestDoc.pdf[...') #1 {main} thrown in
/Users/garys/Documents/Projects/accrivia/code/test/test.php on line 8
Run Code Online (Sandbox Code Playgroud)
输出中提到的tmp文件已创建,但为0字节.如果我在命令行中的消息中执行完整的'gs'命令(使用实际文件),它将成功运行.
使用brew安装ImageMagick和GhostScript.
在PHP中,系统('echo $ PATH'); 给/ usr/bin:/ bin:/ usr/sbin:/ sbin'gs'在/ usr/bin /中
有没有人有任何建议.对异常消息的Web搜索没有任何特定信息.
非常感谢加里.
我自己从未使用过 imageMagick,但文档说它需要 GhostScript 来读取 PDF 文档
PDF support : Requires Ghostscript to read.
Run Code Online (Sandbox Code Playgroud)
编辑:您检查过 GhostScript 是否正常工作吗?
| 归档时间: |
|
| 查看次数: |
2391 次 |
| 最近记录: |