Quickly Resize, Convert Images From Terminal Using Mogrify in Ubuntu

2 min


In this guide, we use Mogrify to help you convert, resize images from the Terminal in Ubuntu. Have a look.

Mogrify is part of the ImageMagick script that comes with ImageMagick installation. ImageMagick is a software package capable of reading, convert and writing images for various formats. It also has 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 a selected few of them.

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

Lenna-Original
Lenna-Original

Resize Image in Ubuntu using Mogrify (Terminal Method)

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

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

mogrify -resize 50% rose.jpg
Lenna-After-Resize
Lenna-After-Resize

Reduce size for all images inside a folder:

mogrify -resize 50% *.jpg

To resize an image to a specific height X width:

mogrify -resize 800x600 *.jpg

Changing Image Format

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

mogrify -format jpg *.png

Changing Image Quality

You can also change quality via specifying the 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 the below command from the 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 on the official page. Check them out. And I hope this guide helped you to get an idea of how to resize images using the Terminal in Ubuntu.


Arindam

Creator and author of debugpoint.com. Connect with me via Telegram, 𝕏 (Twitter), or send us an email.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments