Resize Images From Terminal Using ImageMagick

Resize Images From Terminal Using ImageMagick

ImageMagick – is a free software suite for the creation, modification and display of bitmap images.

There are other applications like GIMP that can be used to convert and resize images, but I like to do it the terminal way, which you might also give a try.

ImageMagick has a lot of additional utilities. Am going to talk about one of them, that is the convert.

If ImageMagick is not installed on your system you can install by running the commands below (Ubuntu)

$ sudo apt-get install imagemagick


After installation, we can now resize our images.

To resize an image

The syntax to follow:

$ convert old_image -resize % new_image


$ convert unixmen.jpg -resize 60% unixmen_new.jpg


Understanding the above command.

If we execute the above command, the image unixmen.jpg will be resized by 60% and saved under a new name unixmen_new.jpg. (Without modifying the original file unixmen.jpg)

Converting image formats

If you want to convert images from one format to another, ImageMagick can help you do that very easily by the help of a single command.


$ convert image_name.jpg image_name.png


$ convert unixmen.jpg unixmen.png


Running the above command quickly converts the image unixmen.jpg to a new format unixmen.png keeping the the first one intact without any modification.

  • LinuxSytesNet

    If anyone is having collection of books and wants to have all the covers from the books, I made a simple python script that executes “convert” automatically and gets the first page of every book. You can do that with bash too.

    #!/usr/bin/env python

    import subprocess

    params = [‘convert’, ‘*.pdf[0]’, ‘%01d.png’]


  • V.

    you can also compress pdf with it, which is quite usefull and works very well when you have large images inside:

    convert -compress jpeg -density 150 file.pdf file-compressed.pdf