Image Magick

Install ImageMagick 7 on Ubuntu

Installing Dependencies for ImageMagick

sudo apt update 
sudo apt install imagemagick 
sudo apt install php-imagick 
sudo systemctl restart apache2 
php -m | grep imagick

Using Imagick with PDF Files

ImageMagick was not designed to securely handle untrusted PDF files. Enabling PDF file handling as shown below is dangerous if any malicious PDF files are ever processed.

Additionally, attempting to work around ImageMagick’s PDF security issues by using Ghostscript directly is also dangerous as Ghostscript is also vulnerable to exploitation when processing malicious PDF files.

In order to allow ImageMagick to process PDF files, you must SSH into your server as root and edit the following file:


Locate the line:

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

Comment out this line by replacing it with the following:

<!--<policy domain="coder" rights="none" pattern="PDF" />-->

Finally, restart PHP:

replace X.Y with your php version

sudo service phpX.Y-fpm-sp restart


sudo systemctl  apache2

Similar Posts

Leave a Reply