#!/bin/sh # a small script to recursively create thumbnails # (c) 1999-2000 by Yves Lafon / W3C - ylafon@w3.org # last change: Mon Jun 5 18:33:52 MET DST 2000 (non recursive mode) # last change Thu Jan 4 00:29:53 MET 2001 added -png # $Id: genethumb,v 1.1 2001/02/22 13:54:04 ylafon Exp $ dirn=".small" recu=1 use_png=0 t_ext="gif" if [ $# -gt 0 ]; then for arg do case "$1" in "-d" ) shift; dirn=$1; shift;; "-l" ) shift; recu=0;; "-png" ) shift; use_png=1; t_ext="png";; "-h" ) echo "Usage: `basename $0` [-l] [-png] [-d ]" exit 1 ;; "*" ) break esac done fi if [ ! -d "$dirn" ]; then mkdir "$dirn"; fi for i in *; do if [ -d $i ]; then if [ $recu -eq 1 ]; then if [ ! "$i" = "$dirn" ]; then echo Generating thumbnails for directory $i (cd $i && $0 -d $dirn $*) echo Directory $i processed! fi fi elif [ -f $i ]; then echo "Working on $i" file_type=`file "$i" | awk '{print $2}'` case "$file_type" in "JPEG" | "GIF" ) ;; * ) anytopnm "$i" 2> /dev/null > /dev/null if [ $? = 1 ]; then ext=`echo "$i" | sed 's/.*\.//g' | tr '[A-Z]' '[a-z]'` case "$ext" in "jpg" | "jpeg" | "gif" ) ;; *) continue; ;; esac fi esac ext=`echo "$i" | sed 's/.*\.//g'` a=`basename $i $ext` b=`dirname $i` echo Creating $b/$dirn/${a}${t_ext} if [ $use_png -eq 0 ]; then anytothumb $* $i > $b/$dirn/${a}${t_ext} else anytothumb -png $* $i > $b/$dirn/${a}${t_ext} fi if [ $? = 1 ]; then echo error while processing $i rm $b/$dirn/${a}${t_ext} fi fi done rmdir $dirn 2> /dev/null > /dev/null