Estimated reading time: 2 minute(s).
How to Resize Images Using ImageMagick on Linux
In this article, we'll walk you through the steps to resize images using ImageMagick, a powerful image manipulation tool, on a Linux system. We'll cover how to install the necessary dependencies and provide commands to resize an image into multiple dimensions. This guide is useful for anyone needing to create various icon sizes for web apps, desktop apps, or other purposes.
Prerequisites
- A Linux operating system (Ubuntu, Debian, Fedora, etc.)
- Terminal access
-
A source image to resize (e.g.,
etf-matcher-square.png
)
Step 1: Install ImageMagick
First, you'll need to install ImageMagick. This tool is available in most Linux distribution repositories. Open your terminal and run the following command based on your distribution:
For Ubuntu or Debian:
sudo apt update
sudo apt install imagemagick-6.q16 # (or equivalent)
For Fedora:
sudo dnf install ImageMagick
For Arch Linux:
sudo pacman -S imagemagick
Step 2: Verify Installation
To verify that ImageMagick has been installed correctly, run:
convert --version
This command should output the version of ImageMagick installed on your system.
Step 3: Resize the Images
Now that ImageMagick is installed, you can resize your images. We'll use a source image named
etf-matcher-square.png
and resize it to several dimensions commonly used for web app icons.
Open your terminal and navigate to the directory containing your source image. Use the following commands to resize the image:
convert etf-matcher-square.png -resize 48x48 etf-matcher-logo-bw-48x48.png
convert etf-matcher-square.png -resize 72x72 etf-matcher-logo-bw-72x72.png
convert etf-matcher-square.png -resize 96x96 etf-matcher-logo-bw-96x96.png
convert etf-matcher-square.png -resize 144x144 etf-matcher-logo-bw-144x144.png
convert etf-matcher-square.png -resize 192x192 etf-matcher-logo-bw-192x192.png
convert etf-matcher-square.png -resize 256x256 etf-matcher-logo-bw-256x256.png
convert etf-matcher-square.png -resize 384x384 etf-matcher-logo-bw-384x384.png
convert etf-matcher-square.png -resize 512x512 etf-matcher-logo-bw-512x512.png
Explanation of the Commands
- convert : This is the ImageMagick command-line tool for image conversion.
- etf-matcher-square.png : The source image file you want to resize.
- -resize 48x48 : Resizes the image to 48x48 pixels. Adjust the dimensions as needed for each command.
- etf-matcher-logo-bw-48x48.png : The output file name for the resized image.
Step 4: Verify the Output
After running the commands, you should have several new images in your directory, each resized to the specified dimensions. You can verify this by listing the files in the directory:
ls -l etf-matcher-logo-bw-*.png
Conclusion
ImageMagick is a versatile tool for image manipulation and can be used on various operating systems, including Linux, macOS, and Windows. This tutorial covered the installation process on a Linux system and provided commands to resize images to multiple dimensions. These resized images can be used for web app icons, mobile app icons, and other purposes.
Feel free to explore more features of ImageMagick to further enhance your image processing tasks.
References
- ImageMagick Official Documentation
- Ubuntu ImageMagick Installation Guide
- Arch Linux ImageMagick Package
Thanks, ChatGPT, for writing this.