#!/bin/sh # genethumb.sh - Génération de thumbnails mortels de ta mère # (c) 3 Jan 1998: version 0.0.4 by Samuel Hocevar # 22 May 2000: version 0.0.5 by Samuel Hocevar # 15 Nov 2000: version 0.0.6 by Samuel Hocevar # with code from Sven Hartge # 13 Dec 2000: version 0.0.7 by Samuel Hocevar # now compatible with old ImageMagick versions # added --rows option # 27 Apr 2003: version 0.0.8 by Sam Hocevar # removed all bashisms # now compatible with all ImageMagick versions # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA version=0.0.8 THFILE=index.html THDIR=.xvpics THEXT=png # change this to jpeg or whatever you want THWIDTH=120 # thumbnail width THHEIGHT=90 # thumbnail height THCOLS=5 # change to set table width -- 0 for no tables if [ "$1" != "" ] then THCOLS=$1 fi echo "genethumb.sh v$version -- report bugs to Samuel Hocevar " echo "usage: genethumb.sh [number of columns]" if [ -w $THFILE ] then echo "saving $THFILE to $THFILE~" mv -f $THFILE $THFILE~ fi if [ ! -d $THDIR ] then echo "creating thumbnail directory $THDIR" mkdir $THDIR fi cat > $THFILE << EOF Index of $PWD

Index of $PWD

generated by genethumb.sh version $version

EOF compteur=0 created=0 find . -type f -maxdepth 1 | sed 's,^\./,,' | while read file do # on vérifie que l'image n'est pas déjà un thumbnail ou une page html, et a # une extension quelconque (à améliorer un peu) case "$file" in *~|*.html|*.htm) echo "* skipping $file" ;; *) failed=0 newfile="$THDIR/tn_$file.$THEXT" echo -n "* $file: " if [ -r "$newfile" ] then echo "thumbnail already exists." else convert -geometry ${THWIDTH}x${THHEIGHT} "$file" "$newfile" >/dev/null 2>&1 if [ ! -r "$newfile" ] then echo "failed creating." failed=1 else echo "done." fi fi if [ "$failed" = "0" ] then created="`expr 0$created + 1`" if [ -e "$newfile.info" ] then read filesize coordinates oldcoords compat < "$newfile.info" fi if expr "$version" ">" "$compat" >/dev/null 2>&1 then read oldcoords filesize << EOF `identify -format '%wx%h %b' "$file" | head -1` EOF coordinates=`identify -format '%wx%h' "$newfile" | head -1` rm -f "$newfile.info" echo $filesize $coordinates $oldcoords $version > "$newfile.info" echo " $newfile.info written." fi j="`echo $file | cut -b1-20`" if [ "$file" != "$j" ] then j="`echo $file | cut -b1-17`..." fi cat >> $THFILE << EOF EOF compteur="`expr 0$compteur + 1`" if [ x"$compteur" = "x$THCOLS" ] then echo " " >> $THFILE compteur=0 fi fi esac done echo "done." cat >> $THFILE << EOF
$file ($oldcoords)
$j
$oldcoords ($filesize)
EOF