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.

SEE ALSO:   A Complete Guide to Create GIF in Linux

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.


We bring the latest tech, software news and stuff that matters. Stay in touch via Telegram, Twitter, YouTube, and Facebook and never miss an update!

Join our Telegram channel and stay informed on the move.

Also Read


Like it? Share with your friends!

Arindam

Creator of debugpoint.com. All time Linux user and open-source supporter. Connect with me via Telegram, Twitter, LinkedIn, 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
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x