Search This Blog

Wednesday, June 17, 2009

Resizing images

Pictures accumulate. The treks, trips, parties and the infinite fun that we've had in the past one year of college has resulted in me filling up half my hard disk with photos. My dear friends have fancy cameras which produce 8 mega pixel images, each occupying almost 2.5MB of my precious hard disk space.

Since an 8 mega pix image is serious overkill, I decided to resize them all to 1600x1200 (2 mega pix, around 1MB). Now that I've turned all linuxy, I was looking for a 'Microsoft Office Picture Manager'-like application for linux when Sriram Kashyap suggested that it'd be way easier to write a shell script to do the job.

So friends, here it is :)
#!/bin/bash
pics=`ls $1 | grep JPG`
for pic in $pics
do
   echo "Converting $1$pic ..."
   convert -size 1600x1200 $1$pic -resize 1600x1200 $1$pic
done
Pass the folder containing your pics as an argument to the script, or just put the script in your folder and double-click :)

1 comment:

Onkar Bhat K said...

I just got a "geek"gasm....\m/