#!/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 # 19 Jun 2003: version 0.0.9 by Chris Ness # better command line option parsing # able to resize final photos (default 640x480) # 5 May 2005: version 0.1.0 by Chris Ness # handles videos and makes a jump link to them (avi,mpg) # only uses the basename of the directory for a title # no longer prints help message with normal use # 8 May 2005: version 0.1.1 by Chris ness # new dependency on `wc` (word count) for videos # I didn't know bash wouldn't let you set a var that is # outside a while loop when you are inside it. Weird! # 1 April 2009: version 0.1.2 by u@curlybracket.net # use utf-8 xhtml, no tables, lists. cleaner css. # 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 progname=$0 version="0.1.2_u" TITLE=`basename $PWD` THEADER=.header THOUT=index.html THFILE=.images # The images are put into this file THVID=.videos THDIR=.xvpics THEXT=jpg # change this to jpeg or whatever you want THWIDTH=120 # thumbnail width THHEIGHT=90 # thumbnail height THCOLS=7 # change to set columns, or use the next 2 lines with a fixed height or both-.. # these lines just create a width and a height for the stylesheet out of the thumbnail values. # LIHEIGHT="`expr ${THHEIGHT} + 40`px" LIWIDTH=${THWIDTH}px RESIZE=7 # Do not resize by default RSZWidth=640 # Default width of resized images RSZHeight=480 # Default height of resized images BACKUP=0 # Do not backup files by default (1 -> backup by default) SIZE=1 # Print the size of the photos to the index file NAME=1 # Print the Name of the photos function usage () { cat <$file" >> $THVID ;; *) 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
  • $file ($oldcoords) EOF if [ "$NAME" = "1" ] then echo "$j" >> $THFILE fi if [ "$SIZE" = "1" ] then echo "$oldcoords ($filesize)" >> $THFILE fi echo "
  • " >> $THFILE ## if you want to have lines of a defined number of images just uncomment this part and adjust the compteur variable # compteur="`expr 0$compteur + 1`" # if [ x"$compteur" = "x$THCOLS" ] # then # echo "
      " >> $THFILE # compteur=0 # fi fi esac done # Build the page, now that we have the components. echo -n "Building HTML page... Header " # Header! cat > $THOUT << EOF Index of $TITLE

      generated by genethumb.sh version $version

      Index of $TITLE


      EOF cat >> $THOUT << EOF
        EOF # Put the image list in the main output file. # echo -n "ImageList " cat $THFILE >> $THOUT cat >> $THOUT << EOF
      EOF # Do we have any videos to list? VIDEOSFOUND=`cat $THVID | wc -l` # If we have videos, list them here. if [ ! "$VIDEOSFOUND" -eq "0" ] then echo -n "Videos " echo "
      " >> $THOUT echo "
        " >> $THOUT cat $THVID >> $THOUT echo "
      " >> $THOUT fi # End of the HTML file. cat >> $THOUT << EOF EOF rm -f $THVID rm -f $THFILE echo "done."