#!/bin/sh
# resizes images, adds copyright, and rotates them
# run it from within the dir that contains images
# needs ImageMagic utilities (convert) and jhead
# Command line options
# > -g geometry : specifies produced image size (default 640x480)
# -g 300x200
# > -c : add copyright (default copyright off)
#options 1 : customizable from cmd lines
SIZE="800x600"
#SIZE="640x480"
ADD_COPYRIGHT="no"
# options 2 : not customizable from cmd lines
copyright="(C) www.sujee.net"
quality="85%"
# process args
while getopts cg: name
do
case $name in
g) SIZE=$OPTARG;;
c) ADD_COPYRIGHT="yes";;
esac
done
#shift $(($OPTIND - 1))
#shift `expr $OPTIND - 1`
echo size=$SIZE
echo add_copyright=$ADD_COPYRIGHT
#echo files=$*
#if [ -z "$files" ]
#then
# echo "no files given.. exiting"
# exit -1;
#fi
#destdir=`date +%d%b%Y-%H.%M.%S`
destdir=$SIZE
mkdir $destdir
for img in *.[Jj][Pp][Gg] *.gif *.png
#for img in $@
do
if [ -f "$img" ]
then
#echo "converting " "$img" " --> " "$destdir/$img"
if [ "yes" == "$ADD_COPYRIGHT" ] # add copyright
then
convert -quality $quality -geometry "$SIZE>" -antialias -pointsize 20 -draw "gravity southEast fill black text 0,12 '$copyright' fill white text 1,11 '$copyright' " "$img" "$destdir/$img"
else # no copyright
convert -quality $quality -geometry "$SIZE>" "$img" "$destdir/$img"
fi
#autorotate image
jhead -autorot "$destdir/$img"
fi
done
|