#!/bin/bash # GPLv3+ # Copyright 2009 Christian Franke TITLE="sublab rack" mkdir thumbs mkdir intimgs cd imgs MAX=0 for i in ./*; do SIZE=$(identify "$i" 2>&1 | cut -d ' ' -f3) if [ "$(expr match "${SIZE}" '\([0-9]*x[0-9]*\)' )" = ${SIZE} ]; then MAX=$((MAX+1)) fi done I=1 for i in *; do SIZE=$(identify "$i" 2>&1 | cut -d ' ' -f3) if [ "$(expr match "${SIZE}" '\([0-9]*x[0-9]*\)' )" = ${SIZE} ]; then SIZEX="$(echo $SIZE | cut -d x -f1)" SIZEY="$(echo $SIZE | cut -d x -f2)" while [ $SIZEX -ge 1021 ] || [ $SIZEY -ge 601 ]; do if [ $SIZEX -ge 1021 ]; then SIZEY=$(( $SIZEY*1020/$SIZEX )) SIZEX=1020 else SIZEX=$(( $SIZEX*600/$SIZEY )) SIZEY=600 fi done cat << "EOF" | sed "s/\\\$I/$I/g" | sed "s/\\\${TITLE}/$TITLE/g" > ../$I.html ${TITLE}

${TITLE} - $I

EOF [ $I -gt 1 ] && echo -e \ " \n \"$((I-1))\"\n " >> ../$I.html cat << "EOF" >> ../$I.html Back to Overview EOF [ $I -lt ${MAX} ] && echo -e \ " \n \"$((I+1))\"\n " >> ../$I.html cat << "EOF" >> ../$I.html
EOF echo " " >> ../$I.html echo " \"$i\"" >> ../$I.html cat << "EOF" >> ../$I.html

Valid XHTML 1.1 [PD]
This image is in the public domain.

EOF echo -n "Generating thumbnail for $i..." WIDTH=$(echo ${SIZE} | cut -dx -f1) HEIGHT=$(echo ${SIZE} | cut -dx -f2) NEWWIDTH=$(( (${WIDTH} * 100) / ${HEIGHT} )) convert "$i" -resize ${NEWWIDTH}x100 "../thumbs/$I.jpg" ; echo " Done." echo -n "Generating intermittient image for $i..." convert "$i" -resize ${SIZEX} "../intimgs/$i" ; echo " Done." I=$((I + 1)) else echo "$i has unknown format, skipping." fi done cd .. cat << "EOF" | sed "s/\\\${TITLE}/$TITLE/g" > index.html ${TITLE}

${TITLE}

EOF for i in $(seq 1 ${MAX}); do echo " \"$i\"" >> index.html done cat << "EOF" >> index.html

Valid XHTML 1.1 [PD]
These images are in the public domain.

EOF