ImageMagick security policy is blocking PDF conversion


ImageMagick security policy is blocking PDF conversion

If you’re trying to create a pdf or convert a pdf, for file size reduction for example, but ImageMagick is giving an error message and is not creating the pdf file then ImageMagick’s security policy could be blocking the conversion.

Creating pdf files with Ghostscript was blocked in the security policy due to a security vulnerability. It was a workaround way to keep security while the issue was addressed in Ghostscript. The vulnerability has been addressed in Ghostscript 9.24. If you have that version or a newer version, then you don’t need this workaround anymore.

Here’s how to check your Ghostscript version and how to remove the workaround in ImageMagick’s security policy:

In a terminal, enter this line and hit enter to run the command:

gs –version

Verify the version and if high enough, proceed to editing the security policy.

In the terminal, , enter this line and hit enter to run the command:

sudo gedit /etc/ImageMagick-6/policy.xml

Enter the root password when prompted. Then proceed to the editor.

Look for the following section in the policy.xml file:

<!– disable ghostscript format types –>

<policy domain=”coder” rights=”none” pattern=”PS” />

<policy domain=”coder” rights=”none” pattern=”PS2″ />

<policy domain=”coder” rights=”none” pattern=”PS3″ />

<policy domain=”coder” rights=”none” pattern=”EPS” />

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

<policy domain=”coder” rights=”none” pattern=”XPS” />

Remove the line with “PDF” in it, save the file and exit gedit.

ImageMagick should now convert your pdf’s without error.

User Agreement

Welcome to Modern Samurai.

An important part of establishing a contract is meeting of the minds. Where many websites hide their user agreement (a.k.a. terms of use, terms of service) at the bottom of their pages, we prefer to be upfront and honest about what you’re getting into. Please download our User Agreement and review it. If you agree, click “Agree” to continue to this Site. If you do not agree, click “Decline” to move away from this Site.