Quickly Resize, Convert Images From Terminal Using Mogrify in Ubuntu


Batch image conversion using Mogrify.

Mogrify is part of ImageMagick script comes with ImageMagick installation. ImageMagick is a software package capable of read, convert and write images for various formats. It also have scripts, options available for cropping, changing colors, applying effects on images and many more features.

The Mogrify script is capable of applying 100+ operations on images. In this tutorial, we will check out selected few of them.

All the processing done on the famous Lenna which is used as standard in image processing.



Resizing Images

The option -resize can resize any image to a given size, by percentage as well. Mogrify also can resize entire list of images in a folder via wildcard processing.

To reduce size of an image by 50%, run below command from terminal:

mogrify -resize 50% rose.jpg


Reduce size for all images inside a folder:

mogrify -resize 50% *.jpg

To resize an image to a specific heightxwidth:

mogrify -resize 800x600 *.jpg

Changing Image Format

Mogrify also can convert image from one format to another. To convert all png images to jpg, run below command:

mogrify -format jpg *.png

Changing Image Quality

You can also change quality via specifying quality value. Quality value can be specified as 1 (lowest image quality and highest compression) to 100 (best quality but least effective compression).

mogrify -quality 50 -format jpg Lenna.png
Lenna-Quality reduced after JPG

Lenna-Quality reduced after JPG

Applying Effects

Mogrify can do lots of image processing as well such as blur, crop etc. To blur an image using Mogrify, run below command from terminal:

mogrify -blur 50 Lenna.png
Lenna-after Blur

Lenna-after Blur

For all other effects and features of Mogrify, visit this page.

Mogrify is by far the fastest, quickest, simplest way of converting images in Ubuntu and in other Linux derivatives. There are other lots of Mogrify options available in official page. Check them out.


You may also like...

Translate »