Apr 23

CameraPhotos….Photos…and more Photos…..ever since I bought the digital camera I have been clicking photos of anything imaginable. I have been on a few trips as well, hence I thought of putting some of the good ones on the web and share it with a few friends, and the best solution for these for me turned out to be Picasa.

So off I went about putting together the photos I wanted to upload to Picasa Web, that is when I realised that I am in a bit of trouble. With each photo being 1.8MB, it was very obvious that I needed to resize the photo’s to a more web appropriate resolution of 1024×768 and at a lower image quality.

I did not directly recollect any software available in Linux which has batch resize options, hence I quickly did a google search and the results surprised me. The solution was a really simple one, that of making use of the package which is by default available in most Linux distro’s – “ImageMagick”, which provides the ‘convert’ command.

Here’s the simple script:
for k in $(ls *.JPG); do convert $k -resize 1024×768 -quality 100 re_$k; done

The working of the above script is simple, here is what it does:
1. Loops through all the JPG files in the current directory.
2. Then for each JPG file in the directory it calls the ‘convert’ command telling it to resize the images to the size 1024×768 and without an quality loss (i.e. 100, means no compression) and saves the resultant file with the prefix ‘re_’.
3. The done statement tells the script to end once all the JPG files are processed.

How is that for a simple and effective solution. Three cheers for command line….who needs bulky and resource hungry GUI programs…? And if you are waiting for the photos…sorry…that is available only to a few select friends and relatives…..but I have posted some of them at the following link http://flickr.com/photos/knithink.


Tags: Tags: , , , , ,


Hits for this post: 2594

2 Responses to “Quick way to resize multiple images in Linux”

  1. Utah SEO Says:

    Thanks for the post i am new to Linux this helps a lot …go Linux!!

  2. NssY Says:

    Just What I was looking for.

Leave a Reply