How to install ImageMagick on Ubuntu? [2 Methods]


This tutorial will guide you through step by step instructions to install ImageMagick on Ubuntu, covering various methods like APT and compiling from source. We'll also explore basic usage, including image conversion and uninstallation steps, catering to both beginners and advanced users.

ImageMagick is a free and open-source software suite used for creating, editing, and converting digital images. It can read and write in multiple image formats, including JPEG, PNG, TIFF, and GIF, among others. ImageMagick is known for its versatility and ability to perform a wide range of image processing tasks. It's particularly powerful in batch processing, allowing the manipulation of numerous images in a single command.

With ImageMagick, users can resize, rotate, apply various effects, adjust colors, and composite images. It's also capable of converting images from one format to another, making it a handy tool for web development and digital media processing. Its command-line interface is ideal for automating repetitive tasks and integrating with other software applications. ImageMagick's ability to utilize multiple computational threads enhances its performance, especially on systems with multi-core processors.

For more detailed information, you can explore ImageMagick's capabilities on its official website.


1. Steps to Install ImageMagick using the APT Package Manager

Installing ImageMagick on Ubuntu using the APT package manager is a straightforward process. Here's a step-by-step guide along with explanations for each step:


1.1 Open Terminal

First, open your terminal. You can do this by searching for 'Terminal' in your Ubuntu system's applications menu or by pressing Ctrl + Alt + T.

How to install ImageMagick on Ubuntu? [2 Methods]


1.2 Update Package Lists

Before installing new software, it's good practice to update your package lists. This ensures you have the latest information about available packages and their versions. Run the command using sudo privilege:

sudo apt update

This command will ask for your password. Enter it to proceed.


1.3 Install ImageMagick

Now, you're ready to install ImageMagick. Use the command:

sudo apt install imagemagick

This command tells the APT package manager to install the ImageMagick package. sudo is used to run the command with superuser privileges, which are typically required for installing software.


1.4 Verify the Installation

After the installation is complete, it's a good idea to verify that ImageMagick is installed correctly. You can check the installed version of ImageMagick by running:

magick --version

You may get below error:

Command 'magick' not found, did you mean:
  command 'magics' from deb magics++ (4.10.1-1)
  command 'magic' from deb magic (8.3.105+ds.1-1.1)
Try: sudo apt install <deb name>

In some versions of ImageMagick, especially older ones like 6.x, the primary command might still be convert rather than magick. Try running:

convert --version
How to install ImageMagick on Ubuntu? [2 Methods]

If this works, it means the version installed uses the older command structure.

You can check the installed rpm version using:

dpkg -l | grep -i imagemagick

Sample Output:

ii  imagemagick                                8:     amd64        image manipulation programs -- binaries
ii  imagemagick-6-common                       8:     all          image manipulation programs -- infrastructure
ii  imagemagick-6.q16                          8:     amd64        image manipulation programs -- quantum depth Q16


1.5 Uninstall ImageMagick (Optional)

Use the following command to uninstall ImageMagick:

sudo apt remove imagemagick

This command tells APT to remove the ImageMagick package. sudo is used to run the command with superuser privileges.

If you want to also remove configuration files associated with ImageMagick, use the purge option instead:

sudo apt purge imagemagick

This command is similar to remove, but it also deletes the configuration files, which is useful if you don't plan on reinstalling ImageMagick and want to clean up all associated files.

After removing ImageMagick, you can also remove any unused dependencies that were installed with it:

sudo apt autoremove

This step helps to keep your system clean by removing packages that are no longer required.


2. Steps to Install ImageMagick on Ubuntu from Source

Installing ImageMagick from source is ideal if you need the latest version or a specific older release that's not available through the standard package repositories. Here's a detailed guide on how to do this:


2.1 Install Required Dependencies

Before you can compile ImageMagick from source, you need to install some essential build tools and libraries. Open your terminal and run the command:

sudo apt install build-essential libltdl-dev libjpeg-dev libpng-dev libtiff-dev libgif-dev libfreetype6-dev liblcms2-dev libxml2-dev git

This command installs the necessary compilers, libraries, and Git. These are required for building ImageMagick and handling various image formats.


2.2 Clone ImageMagick Repository

Next, clone the ImageMagick repository from GitHub to get the source code. Run the following command to perform git clone:

git clone ImageMagick-Source

This command clones the ImageMagick repository into a folder named ImageMagick-Source in your current directory.


2.3 Navigate to the Source Directory

Change your current directory to the ImageMagick source directory:

cd ImageMagick-Source


2.4 Configure the Build Environment

Before compiling, you need to configure the build environment. Run the command:


This script prepares the ImageMagick source code for compilation on your specific system. It checks for necessary tools and libraries, setting up the correct parameters for the build process.


2.5 Compile ImageMagick

Compile the source code by running:


This command will start the compilation process. It may take some time, depending on your system's performance.


2.6 Install the Compiled Binary

After compilation, install ImageMagick onto your system:

sudo make install

This command installs the compiled binaries and libraries into the appropriate system directories.


2.7 Configure Dynamic Linker Run-Time Bindings

Finally, run:

sudo ldconfig /usr/local/lib

This step is essential to ensure your system can find and use the ImageMagick libraries.


2.8 Verify the Installation

Check the installed version of ImageMagick:

magick --version

This confirms that ImageMagick is successfully installed from the source.

How to install ImageMagick on Ubuntu? [2 Methods]


2.9 Uninstall ImageMagick (Optional)

Go to the directory where you initially cloned the ImageMagick source code.

cd ImageMagick-Source

In the source directory, run the following command to uninstall ImageMagick:

sudo make uninstall

This command will use the Makefile (created during installation) to remove the installed files from your system.

After uninstalling, some files or dependencies might still remain on your system. You can manually delete the source directory if you no longer need it:

cd ..
rm -rf ImageMagick-Source

This step removes the source code and any compiled objects in the directory.

If you installed dependencies specifically for ImageMagick and no longer need them, you can remove them using apt-get:

sudo apt-get autoremove -y

This command removes unused packages that were automatically installed to satisfy dependencies for ImageMagick.

After uninstallation, run:

sudo ldconfig

This will update the dynamic linker run-time bindings.


3. Using ImageMagick Commands

ImageMagick offers a wide array of features, including image manipulation, conversion, and editing. You can also refer Shell script to resize image, convert image format in Linux

Here are some of the most used basic and advanced ImageMagick commands:

Command Description Basic Command Example Advanced Command Example
Convert Image Format convert input.jpg output.png convert input.jpg -quality 90 output.png
Resize an Image convert input.jpg -resize 50% output.jpg convert input.jpg -resize 800x600 -quality 80 output.jpg
Create a Thumbnail convert input.jpg -thumbnail 100x100 thumbnail.jpg convert input.jpg -thumbnail 100x100 -background white -gravity center -extent 100x100 thumbnail.jpg
Crop an Image convert input.jpg -crop 300x300+10+20 cropped.jpg convert input.jpg -crop 300x300+10+20 +repage cropped.jpg
Rotate an Image convert input.jpg -rotate 90 output.jpg convert input.jpg -rotate 90 -background white -extent 200x200 output.jpg
Adjust Image Brightness convert input.jpg -modulate 120 output.jpg convert input.jpg -modulate 120,100,100 output.jpg
Create a GIF from Images convert -delay 100 input*.jpg output.gif convert -delay 100 -loop 0 input*.jpg output.gif
Add Text to Image convert input.jpg -annotate +30+30 'Text' output.jpg convert input.jpg -fill blue -pointsize 40 -annotate +30+30 'Text' output.jpg
Combine Images Horizontally convert input1.jpg input2.jpg +append output.jpg convert input1.jpg input2.jpg -background blue +append output.jpg
Combine Images Vertically convert input1.jpg input2.jpg -append output.jpg convert input1.jpg input2.jpg -background blue -append output.jpg
Apply Gaussian Blur convert input.jpg -blur 0x4 output.jpg convert input.jpg -blur 0x8 -brightness-contrast 10x5 output.jpg


4. Summary

In conclusion, this guide covered comprehensive instructions for installing, using, and managing ImageMagick on Ubuntu. We explored various installation methods, including using APT, compiling from source, and using package managers like Snap and Flatpak. These methods cater to different user needs, from those seeking the latest features to those requiring stable versions from official repositories.

For usage, we delved into basic and advanced ImageMagick commands, demonstrating the software's versatility in tasks like image conversion, resizing, cropping, and more. ImageMagick's command-line interface allows for efficient batch processing and complex image manipulations, making it a powerful tool for both casual users and professionals.


Views: 85
Deepak Prasad

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to

Thank You for your support!!