#!/bin/bash ## ## Generate Thumbnails and an index.html in a galleryesque fashion ## Nicholas DeClario ## February 2011 ## $Id: tn,v 1.1.1.1 2011/02/16 13:30:27 nick Exp $ ## ## I'm not using any additional methods to pull in command line options ## at this time so it works as follows. ## ## tn html_file thumb_size columns_in_page ## ## If you want to specify the columns you must also specify the html_file ## and thumb_size first, for example: ## ## tn index.html 64 3 ## ## The defaults, if nothing is specifed is 'index.html' for the html file, ## 64x64 for the thumbnail size and 6 columns. ## HTML=${1:-index.html} TN_SIZE=${2:-64} MAX_COL=${3:-6} TN_DIR=thumbs TITLE="`hostname`:`pwd`" FILE_TYPES="jpg png jpeg gif" [ -d $TN_DIR ] || mkdir $TN_DIR cat <$HTML $TITLE

$TITLE

EOF CNT=0 for i in $FILE_TYPES; do for n in `find -maxdepth 1 -type f -iname \*.$i`; do TN=`basename $n .$i`-tn.$i; convert -resize $TN_SIZE $n $TN_DIR/$TN [ $CNT -ge $MAX_COL ] && \ { echo -e "\n" >>$HTML CNT=0 } cat <>$HTML EOF CNT=$(( CNT + 1 )) done done cat <>$HTML
$n 

Generated on `date` with command '$0 $*' by `whoami`
EOF