logo :: dajhub

Resizing Images with ImageMagick

ImageMagick is free and open-source software which allows you to use the command line to convert and modify images in many formats including GIF, JPEG, and PNG. Using the terminal to manipulate images is, on the whole, straightforward and can save a lot of time.

In Fedora you will first need to install ImageMagick:

$ sudo dnf install ImageMagick

In Ubuntu the commands are:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install imagemagick

In Arch:

$ sudo pacman -S imagemagick

There are a range of different activities you can do using ImageMagick. Below are two commands which I use regularly.

Converting an Image to a Different Format

You may have, for example, an image which you want to convert from a png to jpg format. To do this make sure you are in the directory where your file is. If the picture is in the folder Pictures then in your terminal type, cd Pictures. Once in the correct folder type into the terminal:

$ convert forest.png forest.jpg

Resizing an Image

The convert command can also be used to quickly resize an image. I often use this to resize images for my screen size or my blog. The following command gets ImageMagick to resize an image to 1366 pixels in width and 768 pixels in height:

convert forest.jpg -resize 1366x768 forest.jpg

To find out the other things you can do with the package visit the ImageMagicks github page.