imagick使用readImage报错 Failed to read the file 或者没有报错内容的解决方法
在使用php的imagick插件生成文件的缩图时,发现报错” Failed to read the file”,检查了下服务器配置,虽然很快的解决了,但为了防止以后遇到相同的情况,就记录下解决过程。
imagick插件报错”Failed to read the file”场景
imagick插件报错的代码
if(!extension_loaded('imagick')){
return_json(1, '模块加载失败',[$pdf]);
}
if(!file_exists($pdf)){
return_json(1, '文件路径不正确');
}
$path = $this->file_path( $path1);
try{
$im = new Imagick();
$im->setCompressionQuality(100);
$im->setResolution(120, 120);//设置分辨率 值越大分辨率越高
$im->readImage($pdf); //报错这一行
}catch (Exception $e) {
return_json(1, $e->getMessage(),[$pdf]);
}
imagick 插件在使用 readImage 报如下的错误!
Failed to read the file
imagick使用readImage报错 Failed to read the file 的解决方法
1、安装 ghostscript
我个人的服务器是 centos 系统,执行下面的ssh命令,安装 ghostscript 即可。
ghostscript ssh 安装命令
sudo yum install ghostscript
如果你的服务器系统不是centos 可以使用下面的命令
sudo apt-get install ghostscript
本作品采用《CC 协议》,转载必须注明作者和本文链接
我遇到的问题是使用远程图片报错。。。暂时不知道怎么解决
!!~!