#!/bin/sh
#
# mkthumb *.jpg ...
#
# Create an index.html with thumbnails with hyper-links to the full size jpegs.
#
# Boyd Roberts <[email protected]>
# April 2000 (things happen to me in April, maybe I was a Marine in a former
# life -- ``things happen to Marines''.
#
myname="`basename \"$0\"`"
year="`date '+%Y'`"
name='Boyd Roberts'
email='[email protected]'
index='index.html'
thumb='thumb'
scale()
{
djpeg -pnm "$1" | pnmscale -width 160 -height 120 | cjpeg
}
header='<html>
<head>
<title>
title
</title>
</head>
<body>
<h1>
title
</h1>
<p>
text
<p>
<br>'
footer="<hr>
© $year, $name:
<a href="mailto:$email">$email</a>
</body>
</html>"
case $# in
0)
echo "usage: $myname [ *.jpeg | *.jpg ] ..." 1>&2
exit 1
;;
esac
if [ ! -d "$thumb" ]
then
if mkdir "$thumb"
then
:
else
echo "$myname: Could not mkdir '$thumb'." 1>&2
exit 1
fi
fi
(
echo "$header"
n=
for j
do
# get extension
x="`expr \"$j\" : '.*\.\(.*\)'`"
case "$x" in
jpg|JPG|jpeg|JPEG)
;;
*)
echo "$myname: Can't convert '$j'." 1>&2
continue
;;
esac
echo "<a href=\"$j\"><img src=\"$thumb/$j\" hspace=4 vspace=4></a>"
scale "$j" > "$thumb/$j"
case "$n" in
...)
echo '<br>'
n=''
;;
*)
n="$n."
;;
esac
done
case "$n" in
'')
;;
*)
echo '<br>'
;;
esac
echo "$footer"
) > "$index"
|