Wand Policy Error: error/constitute.c/ReadImage/412
Asked Answered
R

3

26

I am facing the issue while converting pdf to image using Wand:

E           wand.exceptions.PolicyError: not authorized `/opt/sample.pdf' @ error/constitute.c/ReadImage/412

I have already visited the previous stack overflow question here: convert:not authorized `aaaa` @ error/constitute.c/ReadImage/453

Here is my code

def build_image(self, pdf_path, img_path):
    with wand.image.Image(filename=pdf_path) as img:
        img.save(filename=img_path)

My code was working from last 6 months. Now, why am I getting this error?

Please help.

Roseboro answered 8/10, 2018 at 9:49 Comment(1)
Does this answer your question? convert:not authorized `aaaa` @ error/constitute.c/ReadImage/453Spoils
T
63

This is probably due to an security fix of the underlaying package (see https://bugs.launchpad.net/ubuntu/+source/imagemagick/+bug/1796563)

I fixed it for me by editing the /etc/ImageMagick-6/policy.xml and changed the rights for the pdf line to "read":

<policy domain="coder" rights="read" pattern="PDF" />
Taking answered 8/10, 2018 at 11:25 Comment(4)
This fixed my issue. However, I need to login as super user to edit the policy.xml file which is present under /home/xxx/etc/ImageMagick-6/Deterge
this fixed the issue, don't forget to restart apache.Wifehood
If you are using jupyter notebook you need to restart the server Ctrl-C and run it againLixiviate
Command to do this: sed -i 's,<policy domain="coder" rights="none" pattern="PDF" />,<policy domain="coder" rights="read" pattern="PDF" />,g' /etc/ImageMagick-6/policy.xmlRoselynroseman
A
3

Troubleshooting ImageMagick on Debian-based systems.

If encountered with a PolicyError, you may be able to fix it by changing the following line in /etc/ImageMagick-6/policy.xml from this:

<policy domain="coder" rights="none" pattern="PDF" />

to this:

<policy domain="coder" rights="read|write" pattern="PDF" />

(More details about policy.xml available here.)

Taken from the repo

Abhenry answered 5/5, 2020 at 12:33 Comment(0)
E
2

Editing the /etc/ImageMagick-6/policy.xml and changed the rights for the pdf line to "read|write":

<policy domain="coder" rights="read|write" pattern="PDF" />

and restarting the server in my case Jupiter Notebook runtime fixed my issue

Effrontery answered 16/9, 2020 at 11:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.