[ILUG-BOM] Shell Script for resizing an array of images

Roshan d_rosh2001@[EMAIL-PROTECTED]
Tue May 15 18:59:08 IST 2007


Hello List,

I had a task of resizing more than 30 images one by
one (of sizes as large as 3000 x 2000 pixels or a
little lesser than that) to a size 640 x 480 pixels. 

I'm sure, a lot of you click high quality photos
(images of size > than 1 MB) and want to resize them
to send it through email, say as a zip file (if the
receiver wants a copy of the photos). One can upload
the photographs to a photo-sharing website, but one
wouldn't have to log on everytime to view / show the
photos.

I used the command line tool called "convert " (by
ImageMagick) to convert them. Though I knew, I could
play with files in shell scripts I didn't know
anything about the syntax. So, I searched and found
this document 

http://tldp.org/linuxfocus/English/July2001/article211.shtml

Understood the syntax on the page, and wrote a script
to complete the above mentioned task.

#!/bin/sh

	for f in $*;
	do
		convert -resize 640x480 $f t-$f
	done

I have one question.
Is the $* is for argument number (or its type) for the
file that would have to be converted?

There's one thing that I noted while this script was
executing. The processor usage was around 93-100 % and
the memory usage was jumping up and down. Look at the
following picture, to know more. 

http://www.geocities.com/d_rosh2001/system_monitor.png

Please feel free to copy, modify and redistribute this
code, if it helps. :)

--
FSF of India Associate Fellow - http://www.gnu.org.in
S K Somaiya College of ASC- http://www.somaiya.edu/sksasc
ubunturos @ freenode


      Office firewalls, cyber cafes, college labs, don't allow you to download CHAT? Click here: http://in.messenger.yahoo.com/webmessengerpromo.php



More information about the Linuxers mailing list