Annotation of tn1_0/tn, revision 1.1

1.1     ! nick        1: #!/bin/bash
        !             2: 
        !             3: ##
        !             4: ## Generate Thumbnails and an index.html in a galleryesque fashion
        !             5: ## Nicholas DeClario <nick@demandred.dyndns.org>
        !             6: ## February 2011
        !             7: ## $Id$
        !             8: ##
        !             9: ## I'm not using any additional methods to pull in command line options
        !            10: ## at this time so it works as follows.
        !            11: ##
        !            12: ## tn html_file thumb_size columns_in_page
        !            13: ##
        !            14: ## If you want to specify the columns you must also specify the html_file
        !            15: ## and thumb_size first, for example:
        !            16: ##
        !            17: ## tn index.html 64 3
        !            18: ##
        !            19: ## The defaults, if nothing is specifed is 'index.html' for the html file,
        !            20: ## 64x64 for the thumbnail size and 6 columns.
        !            21: ##
        !            22: 
        !            23: HTML=${1:-index.html}
        !            24: TN_SIZE=${2:-64}
        !            25: MAX_COL=${3:-6}
        !            26: TN_DIR=thumbs
        !            27: TITLE="`hostname`:`pwd`"
        !            28: FILE_TYPES="jpg png jpeg gif"
        !            29: 
        !            30: [ -d $TN_DIR ] || mkdir $TN_DIR
        !            31: 
        !            32: cat <<EOF>$HTML
        !            33: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        !            34: 
        !            35: <html xmlns="http://www.w3.org/1999/xhtml">
        !            36: <head>
        !            37: <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        !            38:     <title>$TITLE</title>
        !            39:   </head>
        !            40:   <body bgcolor="#F2F2F2">
        !            41: <h1>$TITLE</h1>
        !            42: <table align="center" border="0">
        !            43: <tr>
        !            44: EOF
        !            45: 
        !            46: CNT=0
        !            47: for i in $FILE_TYPES; do
        !            48:        for n in `find -maxdepth 1 -type f -iname \*.$i`; do 
        !            49:                TN=`basename $n .$i`-tn.$i;
        !            50:                convert -resize $TN_SIZE $n $TN_DIR/$TN
        !            51:                [ $CNT -ge $MAX_COL ] && \
        !            52:                {
        !            53:                        echo -e "</tr>\n<tr>" >>$HTML
        !            54:                        CNT=0
        !            55:                }
        !            56: 
        !            57:                cat <<EOF>>$HTML
        !            58: <td align="center" valign="middle">
        !            59: <a href="$n"><img src="$TN_DIR/$TN" alt="$n" border="0"></a>&nbsp;
        !            60: </td>
        !            61: EOF
        !            62:                CNT=$(( CNT + 1 ))
        !            63:        done
        !            64: done
        !            65: 
        !            66: cat <<EOF>>$HTML
        !            67: </tr>
        !            68: <tr>
        !            69: <td colspan="$MAX_COL">
        !            70: <hr/>
        !            71: <center>
        !            72:        <font size="0">
        !            73:                Generated on `date` with command '$0 $*' by `whoami`
        !            74:        </font>
        !            75: </center>
        !            76: </td>
        !            77: </tr>
        !            78: </table>
        !            79: </body>
        !            80: </html>
        !            81: EOF

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>