Install ImageMagick on Ubuntu Servers

ImageMagick is a component for image manipulation, now widely used by almost all modern servers.
Usually, the version you have available is the most stable or updated release, based on the operating system.

Later in this guide, we will illustrate how to install ImageMagick on Ubuntu servers (20/24), via SSH commands.

Access to your Server via SSH, as Root user and follow this steps:

sudo apt-get remove --purge imagemagick imagemagick-dev

sudo apt-get update && apt-get install -y -qq \

build-essential chrpath debhelper dh-exec dpkg-dev g++ ghostscript gsfonts libbz2-dev \
libdjvulibre-dev libexif-dev libfftw3-dev libfontconfig1-dev libfreetype6-dev \
libjpeg-dev liblcms2-dev liblqr-1-0-dev libltdl-dev liblzma-dev libopenexr-dev \
libpango1.0-dev libperl-dev libpng-dev librsvg2-bin librsvg2-dev libtiff-dev libwebp-dev \
libwmf-dev libx11-dev libxext-dev libxml2-dev libxt-dev pkg-config pkg-kde-tools zlib1g-dev

cd /usr/local/src
sudo wget https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.1-36.tar.gz
sudo tar xzf 7.1.1-36.tar.gz
cd ImageMagick-7.1.1-36

sudo ./configure
sudo make
sudo make install
sudo ldconfig

convert --version

Now, you have the lates ImageMagick version installed on your Server.

Scripts like Dokky Lite and Dokky PRO, require this module installed.
ImageMagick is needed to automatically generate previews of uploaded Documents, if they are in PDF format. However, it is possible that problems may arise, in most cases, related to the permissions that ImageMagick has available.

This is a classic problem: "PDF Not allowed"

The solutions: access via SSH to your server and use:

sudo nano /etc/ImageMagick-YOUR-VERSION/policy.xml

In the file "policy.xml" you have the list of all the file extension allowed to ImageMagick.
Follow the list and search something like this:

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

Change this policy to:

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

Do the same process, if you like to include more extensions like .WebP or .AVIF

Save the file and exit.
Then:

sudo systemctl restart httpd

At this point, ImageMagick will be able to access and manipulate files with these types of extensions.

HostWinds VPS