If you are a Linux user and prefer the Terminal to any other graphical applications, then you will be happy to know that you can also resize, convert, and optimize your images directly in the Terminal with ImageMagick. ImageMagick is a suite of tools for Linux which allows you to manipulate images from the command line. It’s also the image processor behind many graphics-related applications. Here we will show you how to resize your images from the Terminal.

Installing ImageMagick

Before we start, we need to first install ImageMagick on our system.

On Ubuntu or any Debian-based distro:

On Fedora:

On Arch Linux

View the Image Information

With ImageMagick installed, you can now use it to view all the information about an image.:

For example, to check the original dimension of the image, use the following command:

For a photo, you can also view the Exif data:

Resizing Images

Now, let’s try to resize it to 600X300px. The command is:

You can also resize the image to a specific percentage. For example, to scale down “Maketecheasier.png” by 50%, we will use the following command:

The resizing method here is not restricted to scaling down only. You can also use it to upscale an image. For example, to double the size of an image:

If you want to overwrite the original image, you can use the mogrify command instead. It is similar to the convert command, but it is easier to use and it overwrites the original file.

Batch Resize All Images of a Folder

You can easily resize all images in a particular directory. It lets you bulk resize images to specific dimensions. For instance, there are five images in the “Screenshots” directory, and we want to resize the size of these images by 50%. Therefore, we will run the following commands:

Note: Please change the image format from the above command if you are dealing with any other image format rather than JPG.

Change the image format

If you want to change the format of an image, you just have to change the output name to the new format. For example, to convert “Maketecheasier.png” to “Maketecheasier.jpg”, use the following command:

Reduce Image Quality

You can also change the quality of images with ImageMagick. For example, when you take a screenshot on your system, it’s generally captured as a png file in a large size. To reduce the size, you can reduce the screenshot’s quality and convert it into a jpg file:

Rotate Images

To rotate images, all you have to do is use the -rotate option along with the number of degrees you want the image to rotate. For example, the following command creates a 90-degree rotated “screenshot.jpg:”

Create GIF file

If you have a bunch of jpg files and you want to create an animated GIF, ImageMagick can do it too. All you have to do is to load all the jpg files to convert and output it as gif:

Add Watermark to Images

Sometimes you may need to add some text or a logo/graphic to an existing image. For this you use the –append option. In this example, I’m adding a bar to the bottom of my image with a note about the contents.

Remove Exif Data From Image

As a privacy measure, it is sometimes useful to remove all the Exif data from a JPEG photo. You can do it with the mogrify command:

Frequently Asked Questions

Is ImageMagick still maintained?

Yes, ImageMagick has been available since the 1990s and is still maintained regularly. ImageMagick’s new stable update was released on June 20th, 2022 and this suite of tool has active update policies to improve it with the latest releases.

Can I resize images without losing quality?

No, because resizing the image will always reduce its quality. If you reduce the size of an image from 350px to 250px, the picture will be less clear when resized back to its original size.

Is there a graphical application for ImageMagick?

ImageMagick is mainly a command line tool and the developer didn’t create a GUI tool for it. However there are many third-party software that use ImageMagick as its backend. One example is FotoKilof.

Is ImageMagick secure?

Initially, there were some security-related issues in ImageMagick, but now it is safe to use. ImageMagick has a firm security policy to make it safer for a user. The developers also removed bugs that were causing privacy issues.

Our latest tutorials delivered straight to your inbox