Tag: image

How to do a batch image resize in Linux

Today, I realised my ~/Photos directory has crossed 50GB and I badly had to clear them up. I’m definitely not spending time choosing images to delete this time, but just reduce the size of those high resolution images that are eating away my disk space.

I found a way to reduce the size of the image without reducing the quality much.

you need to install it if you don’t have the tool :

sudo apt-get install imagemagick

The most basic way to use convert is to give a file at a time on the command line:

$ mogrify -verbose -resize 50% <filename>

I had to do this for the whole directory and thus replaced the filename with a *

$ mogrify -verbose -resize 50% *

This is a time consuming operation and thus a due patience is required.

We can also mention the dimension of a picture. Say, I reduced the dimension to 1024×768 with this command:

$ mogrify -resize 1024×768 *.jpg

I also found that we can convert all our PNG images in a folder to the JPEG format

$ mogrify -format jpg *.png

NOTE : mogrify will replace your existing file with the updated content. Make sure you are aware of this.

For further info, $ man mogrify to read the manual or go to http://www.imagemagick.org/www/mogrify.html