All of a sudden on 18.04 of Xubuntu, my ability to convert image files to PDF has stopped working.

Normally, I could do the following at the terminal:

$ convert image*.jpg NEW.pdf

to convert a series of image files into one PDF file. Now I get an error. For instance:

$ convert MarsSunset.jpg new.pdf
convert-im6.q16: not authorized 'new.pdf' @ error/constitute.c/WriteImage/1037.

After a few weeks of these errors (and resorting to GIMP to convert the image files by opening and then exporting them to PDF format), I found the following posts on the twitter.

Ross Campbell III @rosscampbell Oct 5

If you update Ubuntu and your web app’s PDF generation breaks, it’s because the latest Ubuntu ImageMagick packages DISABLE generation of .ps, .eps, .pdf, and .xps files !!! You can fix this by editing /etc/ImageMagick*/policy.xml and deleting the ‘disabled’ lines.

Hee-Woong Lim @heewlim Oct 5

Due to recent security vulnerability of ImageMagick, some file format has been disabled. If you wanna convert those file format (such as pdf -> png), you need to modify /etc/ImageMagick/policy.xml https://usn.ubuntu.com/3785-1/

If you click on the security notice, you will see the following:

Due to a large number of issues discovered in GhostScript that prevent it from being used by ImageMagick safely, this update includes a default policy change that disables support for the Postscript and PDF formats in ImageMagick. This policy can be overridden if necessary by using an alternate ImageMagick policy configuration.

That policy change, as noted by Ross Campbell, is disabling PS, EPS, PDF, and XPS files for use with convert. Yeesch.

So, there is a security problem with PDF files. PDF files on Linux systems are usually handled by ghostscript (via the terminal command gs). And, ImageMagick (done through the terminal convert command) uses ghostscript for reading and writing PDF files. Because the security problems are serious and numerous, ImageMagick’s access to PDF files is then cut off.

Granted, through these security flaws in PDF someone could craft a malicious image file that, when converted by ImageMagick into a PDF, will then do very nasty things to your computer.

But, ghostscript has since been updated once and once again with security fixes. How about a fix for ImageMagick to get PDF functionality back? Or, at least an explanation of progress towards fixing this issue?

In the meantime, you can install img2pdf:

$ sudo apt-get install img2pdf

The terminal command to run will be in this format:

$ img2pdf --output NEWFILE.pdf IMAGEFILE.png

Or, as noted by Ross Campbell, you can ignore the security problems and delete the policy restrictions. Sigh.