【发布时间】:2021-01-07 08:07:55
【问题描述】:
我正在本地 ubuntu 20.04 机器上运行一个 laravel 项目,该项目在另一台机器上运行良好。该项目使用 Image Magic 将 PDF 转换为 PNG。当我调用将 PDF 转换为 PNG 的功能时,出现以下错误:
ImagickException 尝试执行安全策略“PDF”不允许的操作@error/constitute.c/IsCoderAuthorized/408
函数看起来:
public function show($id)
{
$book = Book::all()->first();
$file = public_path('' . $book->pdf);
$count = 0;
$im = new \Imagick($file);
$blobList=[];
do {
$page = new \Imagick();
$page->setResolution(300,300);
$page->readImage($file . '['.$count.']');
$page->setImageFormat("jpeg");
header("Content-Type: image/jpeg");
$image = $page->getImageBlob();
array_push($blobList,$image);
$count++;
} while (5> $count);
// $im->resizeImage(200,200,1,0);
return view('notice/showbook', compact('book', 'blobList'));
}
到目前为止,我已经安装了 image magic 和 gs 并参考了this question 接受的答案在policymap.xml 中进行了更改
然而,错误仍然存在。请帮忙!
谢谢,
【问题讨论】:
标签: php laravel imagemagick imagemagick-convert