使用 Wand 将 pdf 转换为图像时,我遇到了这个问题:
E wand.exceptions.PolicyError: not authorized `/opt/sample.pdf' @ error/constitute.c/ReadImage/412
我已经在这里访问了之前的堆栈溢出问题: convert:not authorized `aaaa` @error/constitute.c/ReadImage/453
这是我的代码
def build_image(self, pdf_path, img_path):
with wand.image.Image(filename=pdf_path) as img:
img.save(filename=img_path)
我的代码从过去 6 个月开始运行。现在,为什么我会收到此错误?
请帮忙。
原文由 Prakash Kumar 发布,翻译遵循 CC BY-SA 4.0 许可协议
这可能是由于底层包的安全修复(参见 https://bugs.launchpad.net/ubuntu/+source/imagemagick/+bug/1796563 )
我通过编辑 /etc/ImageMagick-6/policy.xml 为我修复了它,并将 pdf 行的权限更改为“读取”: