Imagick: not authorized

If you get an exception like this when converting using Imagick:

convert-im6.q16: not authorized `my-document.pdf' @ error/constitute.c/ReadImage/412.

Open /etc/ImageMagick-6/policy.xml and look for the lines of

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

and change it to allow read and write

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

A vulnerability has been addressed in Ghostscript 9.24. If you have that or a newer version, you don’t need the workaround anymore. PDFs can contain all sorts of code, and this workaround is there to prevent this.

You can check which version of Ghostscript you are using and consider upgrading below 9.24

gs --version