Mogrify and convert commands are excellent commands to convert or resize the image file in Linux and many more we can do. Please have a look at their man pages for more information The main different comes when creating the file.

Mogrify will replace the original file with a new file where as convert will create a new file with existing old file in the same directory.

In this post we will see how we can use mogrify to
1. Resize an image
2. Convert an image from one formate to other
3. How to reduce the size or quality of an image

In next post we will see how to use convert command to convert image files.

1. Resize an image

mogrify -resize 800X600 file.jpg

Note : Make sure the at the time of resize first number(here it’s 800) should be large. Because the tool will consider this number as constant value. For example if you want to resize a file whose dimensions are 1200×900 to 800×1200 it’s not possible with this option so the actual size of new file is 800×550 though you mention 800×1200

2. Convert an image from one formate to other format

mogrify -format png test.jpg

So This command will convert test.jpg to test.png file with png formats updated to the file

3. How to reduce the size(ie amount of date written to a disk for an image) of an image

#mogrify -quality 80% surendra.jpg

This will reduce the size of the image file by reducing it’s quality

Some case studies :

a. If you want to convert all your photos from jpg to png taken come camera which are located in a folder

mogrify -format png *.jpg

b. If you want your all images taken from camera which are obviously of big size and want to reduce the size and dimensions.

mogrify -resize 800X600 -quality 80% *jpg

This will considerably reduce the file sizes. I did a test drive with this command on my 1.7GB files which are resized to total 350MB with good quality.

And many more we can do if explored more about this wonderful tool.

There is one more command called identify which will give details about the file details such as size, formate, dimensions etc.

How to use it?

#identify test.jpg

To get more info on a file use verbose

identify -verbose test.jpg

Note : This identify will work on any file, don’t think that it will support only images. It support any format or type of file.

The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.