ImageMagick: "not authorized" error when creating PDF

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
peter_b
Chatterbox
Posts: 383
Joined: Tue Nov 12, 2013 2:05 am

ImageMagick: "not authorized" error when creating PDF

Post by peter_b »

[PROBLEM]
I've been using the following ImageMagick command to convert a series of images (jpg, png, etc) into a nice PDF for a few years without any issues:

Code: Select all

$ convert $SOURCE -resize 1800x1800 -compress jpeg -density 150 -units PixelsPerInch -quality 76% $TARGET
Since a recent update of ImageMagick, the command throws the following error:
convert-im6.q16: not authorized `test.pdf' @ error/constitute.c/WriteImage/1037.

[SOLUTION]
It seems that due to a security issue in Ghostscript, ImageMagick disabled PDF generation temporarily by default until that issue is fixed.

Here's a workaround:
In /etc/ImageMagick-6/policy.xml, search for the following rule:

Code: Select all

<policy domain="coder" rights="none" pattern="PDF" />
And either comment it (using HTML comments) or change "rights" to "read|write":

Code: Select all

<policy domain="coder" rights="read|write" pattern="PDF" />
Worked in my case B)


Xubuntu 18.04
ImageMagick 6.9.7-4 Q16 x86_64 20170114
GhostScript 9.26~dfsg+0-0ubuntu0.18.04.14

Thanks to thread "ImageMagick not authorized to convert PDF to an image" (on Stackoverflow).

Additional links:
ArchLinux bug tracker: FS#60580 - imagemagick 7.0.8.14-1 does not work with PDF's
Post Reply