ImageMagick is a free, open-source application installed as a binary distribution or as a source code. ImageMagick can convert, read, write and process raster images. ImageMagick is also available across all major platforms, including Android, BSD, Linux, Windows, Mac OSX, iOS, and many others.
In the following tutorial, you will learn how to install ImageMagick on Ubuntu 20.04 using the APT or Source installation method.
Table of Contents
- Recommended OS: Ubuntu 20.04 – optional (Ubuntu 21.04 and Linux Mint 20)
- User account: A user account with sudo or root access.
- Required packages: Git
Updating Operating System
First, before anything, update your Ubuntu operating system to make sure all existing packages are up to date:
sudo apt update && sudo apt upgrade -y
Installing ImageMagick On Ubuntu 20.04
Install ImageMagick from APT
The easiest and most recommended way to install is using the APT package manager for the average user. If this works correctly, stick with it and do not try and install the source method as it will complicate things more than you need.
First, install ImageMagick using the following command:
sudo apt install imagemagick
Install ImageMagick from Source
This installation choice isn’t recommended for the average user. However, for those wanting to use the source version, follow the steps below.
Firstly, make sure you have GIT installed:
sudo apt install git -y
If you are looking for the latest GIT version, visit our guide, How to Install and Update Latest Git on Ubuntu 20.04.
Now clone the GIT:
git clone https://github.com/ImageMagick/ImageMagick.git /usr/local/src/ImageMagick
Note, depending on how you set your GIT up, and you may need to use the sudo command.
Next, CD into the directory:
Now install the dependencies required:
sudo apt install make build-essential automake
You will now need to use the ./configure command:
Advanced users want more from ImageMagick it is recommended to use –with-modules build:
sudo ./configure --with-modules
Now that you have built and configured the environment, it is time to compile it with the command make.
A handy trick is to specify the -j <number of cpu> as this can greatly increase compiling speed if you have a powerful server. For example, the LinuxCapable server has 6 CPUs, and I can use all 6 or at least use 4 to 5 to increase speed.
sudo make -j 6
After compiling the source code, now run the installation command in your terminal:
sudo make install
After the installation, you need to configure the dynamic linker run-time bindings:
sudo ldconfig /usr/local/lib
Now verify the installation and build:
Updating ImageMagick from Source
If you installed ImageMagick from source using git, re-peat the installation process after you have pulled any new changes from the sources Github using the following terminal command:
sudo git pull
Testing ImageMagick on Ubuntu 20.04
The quickest way to test if ImageMagick is working is to use the convert logo command as follows:
sudo convert logo: logo.gif
Now, if you installed ImageMagick using either the default Ubuntu repository or the ImageMagick source, the test logo.gif will be located in the home directory.
First CD to your home directory, replacing username with your own:
Then list the directory using the ls command:
If you installed from source, look in the source directory you installed ImageMagick in, then confirm if logo.gif has been created.
First, CD to the installation directory, for the tutorial it was:
Then, use the ls command to see if logo.gif is created:
Example Terminal Commands:
Below is a table of commands and tools that can be used with ImageMagick:
|animate||Display an image sequence as an animation.|
|compare||Analyze two images, and visualize mathematical differences between them.|
|composite||Compose one image over another with variable transparency to create a composite image.|
|conjure||Interpret and execute scripts written in MSL, the Magick Scripting Language.|
|convert||Convert images from one file format to another. This tool can also blur, crop, despeckle, dither, and otherwise modify the content of an image.|
|display||A simple image viewer.|
|identify||Display the image dimensions, quality, and other image metadata.|
|import||Capture the screen to an image file.|
|mogrify||Modify an image. Similar to convert, but overwrites the original image.|
|montage||Create an image composed of smaller images. This command can create a single image containing thumbnails of many images.|
|stream||Process image data and store it in a file as it is being streamed from an input source. Useful for situations with slow data streams or huge images whose data processing should begin before the entire image is stored.|
Commands and Conclusion
In the tutorial, you have learned two ways to install ImageMagick on Ubuntu 20.04. Overall, ImageMagick is still quite popular, especially around WordPress websites and plugins, and is a tried and tested option for displaying, creating, converting, modifying, and editing raster images.
For additional information, please visit the official ImageMagick website.