ImageMagick could convert multiple images to a single pdf.


How could reverse the operation?

Convert a pdf of pages to multiple images?

Try the solution

$ convert test.pdf test-%02.png
convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408.
convert-im6.q16: no images defined `test-%02.png' @ error/convert.c/ConvertImageCommand/3258.

gs was installed

$ gs --version

Ubuntu version

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 19.04
Release:    19.04
Codename:   disco
  • Maybe stackoverflow.com/q/2693820/12181862 has some tips. – DK Bose Oct 18 '19 at 2:13
  • Which version of Ubuntu are you running? Looks like some judicious editing of /etc/ImageMagick-7/policy.xml should sort out the issue: add <policy domain="coder" rights="read | write" pattern="PDF" /> before </policymap> – andrew.46 Oct 18 '19 at 2:57
  • Ubuntu 19.04 @andrew.46 – Calculus Oct 18 '19 at 3:01
  • This error message is also fixed by the below answer convert-im6.q16: not authorized filename.pdf @ error/constitute.c/WriteImage/1037. – M.Viking Dec 10 '19 at 14:26

Interestingly enough ImageMagick under 19.04 (and other Ubuntu releases!) disables many ghostscript format types. This can be seen in this snippet from /etc/ImageMagick-6/policy.xml:

  <!-- disable ghostscript format types -->
  <policy domain="coder" rights="none" pattern="PS" />
  <policy domain="coder" rights="none" pattern="EPS" />
  <policy domain="coder" rights="none" pattern="PDF" /> <------- Here!!
  <policy domain="coder" rights="none" pattern="XPS" />

Of course I have added the arrow to catch your attention :). Modify this arrowed line to:

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

You can use your favourite text editor to accomplish this, using elevated privileges, or perhaps simply use the following sed one-liner:

sudo sed -i_bak \
's/rights="none" pattern="PDF"/rights="read | write" pattern="PDF"/' \

And then all should be well, I have tested this comprehensively on my own 19.04 VM where the conversion you are after works flawlessly...

If you wish to change the settings back to the default the following one liner will restore the backup file created in the run with sed:

sudo mv /etc/ImageMagick-6/policy.xml_bak /etc/ImageMagick-6/policy.xml

How cool is the command line!

  • Thank you! This has been bothering me all morning! – Pedroski Jan 5 '20 at 1:20
  • @Pedroski Good to hear it worked for you :) – andrew.46 Jan 5 '20 at 2:52
  • what about Security issue with PostScript PDF described in cromwell-intl.com/open-source/pdf-not-authorized.html ? Is that any concern ? – equivalent8 Jan 14 at 8:57
  • @equivalent8 Fair call, note that the writers of this article stated: 'If we instead are talking about your desktop, then you might want to enable those data types for ImageMagick. '. These are changes I am happy to have on my own system... – andrew.46 Jan 14 at 9:17
  • Thanks, it works for Redmine 4.x, Ubuntu 20.04 LTS – Sunding Wei Feb 1 at 6:02

Another reason for getting that same error is that the source images are too wide, too tall or too heavy.

The /etc/ImageMagick-6/policy.xml file controls what is acceptable as an image. Maximum width and height are set like this:

<policy domain="resource" name="width" value="10KP"/>
<policy domain="resource" name="height" value="10KP"/>

10KP stands for 10000 pixels. If your image is larger than that running identify will not show the image info in the terminal and the image is basically out of reach for Image Magick.

Other common properties that affect images being available or not are: memory, map, area and disk.

Here the document describing policy.xml: https://imagemagick.org/script/security-policy.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.