ImageMagick security policy is blocking PDF conversion
2 April 2022 2023-07-15 15:28ImageMagick 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.