Imagemagick无法读取文件(MAMP) [英] Imagemagick unable to read the file (MAMP )
本文介绍了Imagemagick无法读取文件(MAMP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的MAMP开发环境中安装了Imagemagick扩展,并且PHP信息显示正确安装了imagemagick。但是,我收到以下异常:
I have installed Imagemagick extension on my MAMP dev environment and PHP info showing imagemagick installed properly. However, I am receiving the following exception:
PHP Fatal error: Uncaught exception 'ImagickException' with message
'Unable to read the file:
/Applications/MAMP/htdocs/image/demo.pdf'
in /Applications/MAMP/htdocs/image/index.php:8
Stack trace:
#0 /Applications/MAMP/htdocs/image/index.php(8): Imagick->__construct('/Applications/M...')
#1 {main}
thrown in /Applications/MAMP/htdocs/image/index.php on line 8
源代码:
$pdf_file = '/Applications/MAMP/htdocs/image/demo.pdf';
echo $pdf_file;
$save_to = '/Applications/MAMP/htdocs/image/demo.jpg';
$img = new imagick($pdf_file);
//reduce the dimensions - scaling will lead to black color in transparent regions
$img->scaleImage(800,0);
//set new format
$img->setImageFormat('jpg');
//save image file
$img->writeImages($save_to, false);
编辑1:
I我正在使用 brew
来管理包裹。
I am using brew
for managing packages.
我的MAMP配置:
Imagick扩展(php.ini):
Imagick extension(php.ini):
[imagick]
extension="/usr/local/Cellar/php55-imagick/3.1.0RC2/imagick.so"
Envvars:
路径:
/Applications/MAMP/Library/bin/envvars
内容:
#if test "x$DYLD_LIBRARY_PATH" != "x" ; then
# DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#else
#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib"
#fi
#export DYLD_LIBRARY_PATH
#DYLD_LIBRARY_PATH="/Applications/MAMP/bin/ImageMagick/ImageMagick-6.8.9/lib:/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH
推荐答案
首先检查你的pdf文件路径:
first check your pdf filepath:
if (! is_readable('/Applications/MAMP/htdocs/image/demo.pdf')) {
echo 'file not readable';
exit();
}
如果文件可读,请检查: https://github.com/delphian/drupal -convert-file / wiki /在Mac-OSX-for-PHP-and-MAMP上安装-ImageMagick-on-MacMOSX
if file is readable, check this: https://github.com/delphian/drupal-convert-file/wiki/Installing-ImageMagick-on-Mac-OSX-for-PHP-and-MAMP
这篇关于Imagemagick无法读取文件(MAMP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文