#!/bin/sh

# This is a small script that rotates for images with rotate tags, optimised images, put the copyright notice
# Copyright Prakash Advani - released under GPL license - http://www.gnu.org/copyleft/gpl.html

#Define your variables

#Size for the output image - This can either be a fixed size say 1024x768, etc or a percentage eg. 50%

size=1024x768

#Source image extension

source=jpg
#source=png
#source=jpeg

#define the font, color, size to put the copyright notice.

font=helvetica
fontcolor=white
fontsize=14

#define the copyright notice to put

#copyright="© Prakash Advani - www.cityblogger.com"


echo Conversion tool by Prakash Advani
echo Space of the source images
du -sh  
echo creating directory web where all the converted images will be stored
mkdir web
for img in `ls *.$source`
do
echo
echo processing $img
echo checking for rotate tag - if exists, it will rotate the image and remove the rotate tag
jhead -autorot $img
echo converting the size to $size  and putting the  copyright notice 
convert -resize $size -font $font  -fill $fontcolor  -pointsize $fontsize  \
-draw 'text 10,20 "© Prakash Advani - www.cityblogger.com"' \
$img web/$img.jpg
done
cd web
echo changing all upper case file names to lower case
chcase *
ls -ltrh *.jpg
echo Space used by the converted images
du -sh

