Automatically converting photos to internet size

What is this about?

Have photos from your camera and want to share them online, but in a way that leaves you some webspace and those people who want to see them some bandwith? This linux script batch converts all images in the current directory to 640 times 480 (or 480x640, as appropriate), but you can of course easily modify this target size. Everything very basic, though I could not find a ready script online.
If you don't have an automatic slideshow script yet you might want to use this one.

The batch conversion script

The script should work on all standard Linux distributions. Simply copy the following text, put into a new text file. Save that file, ideally in some directory that is searched for commands (one of your $PATH dirs) and give it the "executable" flag.

#!/bin/bash
echo "This will resize all jpg images in the current directory to 640x480 (or 480x640, as appropriate), an optional paramter will be prefixed to result files."
for i in *.jpg ;
do 
SIZEX=$(identify $i | egrep -o '[0-9]+x' | egrep -o '[0-9]+')
SIZEY=$(identify $i | egrep -o 'x[0-9]+' | egrep -o '[0-9]+')
if(test $SIZEX -ge $SIZEY;)then
  convert -size 640x480 $i -resize 640x480 $1_$i;
else
  convert -size 480x640 $i -resize 480x640 $1_$i;
fi
echo "resized image $1_$i created." ; 
done 

Rotation

You might need to rotate images, this can be simply done by

convert -rotate 90 $1 $1
(For a script that is, with $1 the pics filename given as parameter to the script; here for 90 degrees).


I do not guarantee the correctness/adequateness of the data and the information given on this side and thus deny any responsibility for your use of it.
Johannes Knabe (jknabe@panmental.de)
v0.1 St Albans, United Kingdom, 14.01.2006 (2006/01/14)
My Homepage is http://panmental.de