#!/bin/sh # # Photoweb: makes nice html of jpegs in a directory. # # Version 3.0 # # By: Phil Wherry , Eric Johnston # # To install, just put it somewhere in your path. Make sure you have # the utilities cjpeg, djpeg, exiftags, and wwwis (aka wwwimagesize). # To run, just get in your photo directory and run it: # # cd directoryfullofjpegs/ # photoweb # # $Id: photoweb,v 1.9 2003/06/02 17:49:45 ejohnst Exp $ # CWD="`pwd`" SSCALE="1/8" MSCALE="1/2" CAPTIONS="captions.txt" COLUMNS=3 THUMBQUALITY=75 EXIFOPTS="" # Add -l here if you have a removable lens. CAMERAHDR="YES" # Set to NO if you have a mix of cameras. n=0 if [ -f $CWD/index.html ]; then echo "$CWD/index.html exists - stopping" exit 1 fi title=`basename $CWD` cat < index.html $title Photo Index

$title

Photo Index

EOF cat < info.html $title Photo Info

$title

Photo Info

EOF for jfile in *.JPG; do [ "X$jfile" = "X*.JPG" ] || mv $jfile `basename $jfile .JPG`.jpg done for jfile in *.jpg; do fname=`echo "$jfile" | tr -d "'\ \""` bname=`basename "$fname" .jpg` sname="$bname-s.jpg" # Let's ignore previously created thumbnails. t1=`basename "$bname" "-m"` t2=`basename "$bname" "-s"` [ "$bname" = "$t1" ] || continue [ "$bname" = "$t2" ] || continue # Rename files so they're somewhat standard. (Back up file beforehand.) [ "$jfile" = "$fname" ] || [ -f "$jfile~" ] || cp -p "$jfile" "$jfile~" [ "$jfile" = "$fname" ] || mv -i "$jfile" "$fname" echo "Processing $fname ($jfile)" # Create thumbnail and medium-sized versions of the pics. [ -f "$bname-m.jpg" ] || \ djpeg -scale $MSCALE "$fname" | cjpeg -quality 90 > $bname-m.jpg [ -f "$sname" ] || \ djpeg -scale $SSCALE "$fname" | cjpeg -quality $THUMBQUALITY > $sname # Try to grab a caption for the photo. if [ -f $CAPTIONS ]; then capt=`grep "^$bname " $CAPTIONS | tr "\"" "'" | cut -f2` subhead=`grep "^$bname " $CAPTIONS | tr "\"" "'" | cut -f3` fi if [ "X$capt" != "X" ]; then echo " $capt" fi # First time through, grab camera info. if [ $n -eq 0 ]; then case ${CAMERAHDR} in [Yy][Ee][Ss]) echo "

" >> info.html exiftags -cq $EXIFOPTS "$fname" | sed 's/: / /' | \ awk 'BEGIN { FS = " " } { printf "", $1, $2 }' >> info.html echo "
%s: %s
" >> info.html ;; *) EXIFOPTS="-c $EXIFOPTS" echo "
" >> info.html ;; esac fi n=$(($n + 1)) # Write a subheading. if [ "X$subhead" != "X" ]; then cat <> index.html EOF n=1 fi # Populate the index. cat <> index.html EOF # Populate the Exif info. cat <> info.html " >> info.html [ $(($n % $COLUMNS)) -eq 0 ] && echo "" >> index.html done cat <> index.html

$subhead

$fname
[med] | [big] | [info]

$capt

$fname
 
$fname   EOF exiftags -iq $EXIFOPTS "$fname" | sed 's/: / /' | \ awk 'BEGIN { FS = " " } { printf "\n", $1, $2 }' >> info.html echo "
%s:%s


photoweb EOF wwwis index.html info.html rm -f index.html~ info.html~