Wand Policy Error:error/construct.c/ReadImage/412

Pra*_*mar 11 python-3.x wand

我在使用Wand将pdf转换为图像时遇到了这个问题:

E           wand.exceptions.PolicyError: not authorized `/opt/sample.pdf' @ error/constitute.c/ReadImage/412
Run Code Online (Sandbox Code Playgroud)

我已经访问过此前的堆栈溢出问题: 转换:未授权`aaaa` @ error/construct.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)
Run Code Online (Sandbox Code Playgroud)

我的代码在过去6个月内处于工作状态.现在为什么我得到错误.

请帮忙.

Dom*_*elt 40

这可能是由于底层包的安全修复(参见https://bugs.launchpad.net/ubuntu/+source/imagemagick/+bug/1796563)

我通过编辑/etc/ImageMagick-6/policy.xml修改了它,并将pdf行的权限更改为"read":

<policy domain="coder" rights="read" pattern="PDF" />
Run Code Online (Sandbox Code Playgroud)

  • 如果您使用的是 jupyter notebook,则需要重新启动服务器 Ctrl-C 并再次运行 (2认同)