Linux ImageMagick error: attempt to perform an operation not allowed by the security policy PDF


Example error:

root@tutorialspots ~/pdf # convert "myfile.pdf" page.png
convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/421.
convert-im6.q16: no images defined `page.png' @ error/convert.c/ConvertImageCommand/3229.

The error you are seeing comes from a security restriction applied by ImageMagick. In some cases, default security policies do not allow converting PDF files to images without specific permission. To resolve this issue, you can adjust ImageMagick’s security settings or use a different approach such as using poppler-utils.

However, if you still want to continue using ImageMagick and get an error about security restrictions, you can try extending ImageMagick’s security policy to allow conversion from PDF to images. Here’s how:

Step 1: Open ImageMagick’s security policy configuration file:
sudo nano /etc/ImageMagick-6/policy.xml

Step 2: Find and edit PDF rules:
find line:

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

change it to:

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

This will grant ImageMagick permissions to read and write PDF files.

Save and close the configuration file (Ctrl + X, then Y, and Enter).

Done!

Leave a Reply