#!/bin/bash
# 
#  Creates thumbnail pictures and outputs an index file for browsers
#  thumbie -h for usage
#
FILES="$@"
case "$FILES" in
    -h) cat <<END >&2
Creates thumbnail pictures and outputs an index file for browsers
Usage:  thumbie <files>
Typical usage: thumbie *.JPG > index.html
         + edit index.html as needed + do 'chmod a+r index.html'
END
        exit 0;;
     *) ;;
esac
echo "<HTML><HEAD>"
echo "<TITLE>Title goes here</TITLE>"
echo "</HEAD><BODY BGCOLOR=\"#ffffff\">"
echo "<H1>Details go here</H1>"
echo "<P>Click on images to obtain larger version.</P>"
echo "<P>"
for i in $FILES
do
  chmod a+r $i
  djpeg $i | pnmscale -xysize 150 150 | cjpeg -opti -progr -qual 75 > TN_$i
  chmod a+r TN_$i
  echo "<A HREF=\"$i\"><IMG SRC=\"TN_$i\"></A>"
done
echo "</P></BODY></HTML>"

