ImageMagick is a powerful, open-source software used to create, edit, and manipulate images. This versatile software is widely used by graphic designers, photographers, and web developers to perform various image-related tasks, from resizing images to adding special effects. With its wide range of features and capabilities, ImageMagick is a must-have tool for anyone working with images in Ubuntu.
Features of ImageMagick:
- Image Editing: ImageMagick offers a wide range of tools for editing images, including resizing, cropping, and adding special effects.
- Compatibility: ImageMagick is compatible with many image formats, including JPEG, PNG, GIF, and TIFF.
- Command Line Interface: ImageMagick offers a command-line interface that makes it easy to automate image-related tasks.
- Batch Processing: ImageMagick allows you to perform batch processing of multiple images, making it ideal for large projects.
- Scripting: ImageMagick can be used in scripts to perform image-related tasks, making it ideal for developers.
- Open-Source: ImageMagick is an open-source tool, making it freely available to anyone.
The following tutorial will teach you how to install ImageMagick on Ubuntu 22.04 Jammy Jellyfish LTS or Ubuntu 20.04 Focal Fossa LTS using the APT default repository on Ubuntu or downloading the source and compiling it using the command line terminal.
Table of Contents
Step 1: Update Ubuntu
The first step in installing ImageMagick on Ubuntu is ensuring your system is up to date. This will ensure that you have the latest security updates and that your system is compatible with ImageMagick. To update your system, open the terminal and run the following command.
sudo apt update && sudo apt upgrade
Install Required Libraries
ImageMagick relies on several libraries to function correctly. To install these libraries, run the following command.
sudo apt install libpng-dev libjpeg-dev libtiff-dev
Method 1: Install ImageMagick with APT
The easiest and most recommended way to install it 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.
For the APT method, install ImageMagick using the following command.
sudo apt install imagemagick
And that is it; for alternative installation methods, check out the next section on how to compile ImageMagick.
Method 2: Install ImageMagick with Source
The alternate installation method involves cloning the ImageMagick GIT repository and compiling the application. This option is not suitable for the average user. However, follow these steps if you want to utilize the source version to access the latest release or a specific older release.
Before proceeding with this installation method, you must ensure that you have GIT installed on your system. You can check this by running the following command in the terminal.
This command will display the version of GIT currently installed on your system. If GIT is not installed, you can install it by running the following command.
sudo apt install git
Open the terminal and navigate to the desired location where you want to store the cloned repository, and then run the following command to clone the repository.
git clone https://github.com/ImageMagick/ImageMagick.git
If you prefer, you can specify the location of the cloned repository to “/usr/local/src/ImageMagick” by using the following command.
git clone https://github.com/ImageMagick/ImageMagick.git /usr/local/src/ImageMagick
It’s important to note that depending on your GIT/user privilege configuration, you may require using the sudo command while cloning the repository, for example.
sudo git clone https://github.com/ImageMagick/ImageMagick.git /usr/local/src/ImageMagick
After cloning the ImageMagick repository, it’s time to navigate to the directory where it was cloned. The location may vary depending on your specific setup, but the general steps are as follows:
Or if you cloned it to “/usr/local/src/ImageMagick.”
To continue the installation process, you must install the dependencies required to compile ImageMagick. The dependencies include various libraries and tools necessary for the compilation process. You can install the dependencies by running the following command in the terminal.
sudo apt install build-essential libltdl-dev libjpeg-dev libpng-dev libtiff-dev libgif-dev libfreetype6-dev liblcms2-dev libxml2-dev
With the dependencies installed, the next step is to run the ./configure command to prepare the ImageMagick source for compilation.
This command will check for any dependencies or configurations required to compile ImageMagick. The ./configure command will display an error message if any dependencies or configurations are missing. In this case, you will need to install the missing dependencies or resolve the configuration issues before proceeding with the next step.
For advanced users seeking more functionality from ImageMagick, it’s recommended to build the application with the –with-modules option. This option enables the installation of additional optional features and modules, providing a more robust and versatile ImageMagick experience. To build ImageMagick with the –with-modules option, include it in the ./configure command.
Example output if successful:
By including this option, you can ensure that you have access to the full range of features and functionality offered by ImageMagick.
With the environment built and configured, it’s time to compile ImageMagick. This is done using the make command.
Example output if successful:
This command will compile the ImageMagick source code into a usable application. The compilation process may take several minutes, depending on your system specifications. After the compilation is complete, you can proceed with the next step.
With the source code compiled, the next step is to run the installation command. This will install ImageMagick on your Ubuntu system.
sudo make install
Example output if successful:
This command will install ImageMagick on your system. Once the installation is complete, you can start using ImageMagick.
Once the installation of ImageMagick is complete, the final step is to configure the dynamic linker run-time bindings. This step is important as it ensures that your system can locate and use the ImageMagick libraries at run-time.
sudo ldconfig /usr/local/lib
This command will configure the dynamic linker run-time bindings, making ImageMagick accessible and usable on your system. After running this command, you should be able to use ImageMagick without any issues; failure to do this may result in the following error in your terminal.
magick: error while loading shared libraries: libMagickCore-7.Q16HDRI.so.10: cannot open shared object file: No such file or directory
It’s important to note that the dynamic linker run-time bindings may need to be reconfigured if you upgrade or reinstall ImageMagick in the future. In such cases, repeat the steps above to reconfigure the dynamic linker run-time bindings.
Once you have installed ImageMagick, you can verify the installation by running the following command.
Version: ImageMagick 7.1.0-62 (Beta) Q16-HDRI x86_64
Examples of ImageMagick Commands
Converting an Image Format
ImageMagick can also convert an image from one format to another. For example, if you want to convert a JPG image to PNG, you can use the following command.
convert input.jpg output.png
Creating a Thumbnail
ImageMagick can also be used to create a thumbnail from an image. The command for this is:
convert input.png -thumbnail 200x200 output.png
This command will create a 200×200 thumbnail from the image “input.png” and save the result as “output.png.”
Resizing an Image
You can use ImageMagick to resize an image to a specific dimension. The command for this is.
convert input.png -resize 200x200 output.png
This will resize the image “input.png” to a 200×200 image and save the result as “output.png.”
Adding Text to an Image
You can add text to an image using ImageMagick. The command for this is.
convert input.png -font Arial -pointsize 36 -fill black -draw "text 20,50 'Hello World'" output.png
This command will add the text “Hello World” to the image “input.png” using Arial font and 36-point font size. The text will be filled with black and placed at the position (20,50). The result will be saved as “output.png.”
In conclusion, installing ImageMagick on Ubuntu is a straightforward process that can be achieved through the terminal or by cloning the ImageMagick GIT repository. The former method is shorter and more suitable for the average user, while the latter is more complex but offers the option to use the latest or a specific older release. Regardless of your chosen method, it is important to follow the steps closely to ensure a successful installation. Before proceeding, install the required dependencies, clone the repository (if applicable), and run the appropriate commands in the terminal. After the installation, you can verify its success by running a few test commands to ensure everything works as intended.
For additional information, please visit the official ImageMagick website.
Frequently Asked Questions
Can I install ImageMagick on other Linux distributions besides Ubuntu?
Yes, ImageMagick is available for many Linux distributions, including Debian, Fedora, and CentOS.
Where does ImageMagick install on Ubuntu?
ImageMagick installs in the /usr/bin/ directory on Ubuntu.
What does ImageMagick do on Ubuntu?
ImageMagick is a powerful tool for editing and manipulating images in Linux systems. It provides a range of features to help you create high-quality images.
What is the benefit of manually installing ImageMagick over the APT method on Ubuntu?
The benefit of manually installing ImageMagick over the APT method is that you can install a specific version of ImageMagick that may not be available in the APT repository.
What is PHP ImageMagick on Ubuntu?
PHP ImageMagick is a library that provides an interface between PHP and ImageMagick on Ubuntu. It allows developers to use ImageMagick’s image manipulation capabilities within PHP scripts.
How popular is ImageMagick on Ubuntu systems?
ImageMagick is a widely used tool in the Linux community and is particularly popular on Ubuntu systems.
Are Imagick and ImageMagick the same on Ubuntu?
Yes, Imagick and ImageMagick are the same things. The name “Imagick” refers to the PHP extension for ImageMagick, which provides an interface between PHP and ImageMagick.