#!/bin/bash # ########################################## # Adapted from bbips (www.bbips.org) by # # Murdoch J. Gabbay # # On the web at www.gabbay.org.uk # ########################################## if [ -n "$1" ]; then INDEX=$1 else echo echo "Image Gallery Creation Function" echo "----------------------------------" echo By Murdoch J. Gabbay echo "www.gabbay.org.uk" echo "Version 1.0, 1 October 2006" echo echo "Run gallerymake.sh in a directory containing" echo "directories of the form " echo "./generic-header.html" echo "./[gallery name 1].dir" echo "./[gallery name 1].dir/separator.html" echo "./[gallery name 1].dir/image1.jpg" echo " ...." echo "./[gallery name 1].dir/imagen.jpg" echo "./[gallery name 2].dir" echo "./[gallery name 2].dir/separator.html" echo "./[gallery name 1].dir/image1.jpg" echo " ...." echo "./[gallery name 1].dir/imagen.jpg" echo " ..." echo "./[gallery name n].dir" echo "./[gallery name n].dir/separator.html" echo "./[gallery name 1].dir/image1.jpg" echo " ...." echo "./[gallery name 1].dir/imagen.jpg" echo "./generic-footer.html" echo echo echo "index.html will start with the text in generic-header.html" echo "and then separator.html for the first gallery," echo "then the photos of the gallery " echo "and then separator.html for the second gallery," echo "then the photos of the gallery," echo "and so on ..." echo "and then generic-footer.html" echo echo "In addition the following translations are carried out" echo "on the filenames of the images:" echo echo "\"-\" ---> \" \"" echo "\"xqgq\" ---> \"\?\"" echo "\"xqge\" ---> \"!\"" echo "\"xqgc\" ---> \",\"" echo "\"xqgs\" ---> \".\"" echo "\"xqw..\" ---> \"\" Here the two dots represent any two chars," echo " useful for ensuring photos appear in order." echo "For examples see www.gabbay.org.uk -> personal -> photos" echo echo "----------------------------------------------------" echo "Usage: gallerymake.sh [index.html]" echo echo "The script will remove index.html if it exists" echo "it will then generate index.html as described above." echo exit 1 fi echo "Thumbnail creation starting" #if -e thumbnails; #then #echo "Not creating thumbnails; directory already exists" #else mkdir thumbnails #sleep 1 echo "Thumbnail directory has been created" #sleep 1 #for i in *.JPG ; #changed to next line for various image types #for i in *.* ; # change [.jpg,.JPG] to something else if you want to work with some other image formats for dirname in *[.dir] ; do mkdir thumbnails/$dirname cd $dirname for i in *[.jpg,.JPG] ; do if [ -e ../thumbnails/$dirname/$i ]; then echo "Not creating thumbnail $i; already exists" else convert -size 200x200 $i -resize 200x200 -quality 90 tn_$i; mv tn_$i ../thumbnails/$dirname/$i ; echo "Creating thumbnail $i " ; fi done cd .. done #fi echo "All thumbnails created" echo " " # Create white borders on images in thumbnail gallery #echo "Creating borders on all images" #echo " " #cd thumbnails # for i in *.* ; # change [.jpg,.JPG] to something else if you want to work with some other image formats #for i in *[.jpg,.JPG] ; #do convert -bordercolor $bordercolor -border 2x2 $i $i #echo "Border put on image $i " ; #done #echo " " #echo "Borders created on all images" #cd .. # need check to see if an index file already exists ...... # if we are rerunning the script... the next line removes the previous version of the index file. rm $INDEX # Create the html header echo " " echo "Creating index file" # Below is the start of the html file. You can change the meta tags to reflect YOUR information if you wish. # Specifically the description and keywords sections. cat generic-header.html >> $INDEX # Create the table of images # for badname in *jpg # change [.jpg,.JPG] to something else if you want to work with some other image formats for dirname in *[.dir] ; do cat $dirname/separator.html >> $INDEX #echo "" >> $INDEX echo "
" >> $INDEX echo "" >> $INDEX count=0 cd $dirname for badname in *[.jpg,.JPG] ; do if [ $count -eq 3 ] ; then echo "" >> ../$INDEX echo "" >> ../$INDEX echo " " >> ../$INDEX echo "" >> ../$INDEX echo "" >> ../$INDEX echo "" >> $INDEX echo "" >> $INDEX echo "
" >> ../$INDEX count=1 else echo "" >> ../$INDEX count=$(( $count + 1 )) fi rename="$(echo $badname | sed 's/.jpg//;s/-/ /g;s/xqgq/\?/g;s/xqge/\!/;s/xqgc/,/g;s/xqgs/./;s/xqw..//g')" echo "
" >> ../$INDEX echo "" >> ../$INDEX echo "
" >> ../$INDEX echo "$rename

" >> ../$INDEX echo "
" >> ../$INDEX done cd .. echo "
" >> $INDEX done echo "
" >> $INDEX echo "
" >> $INDEX echo "
" >> $INDEX cat generic-footer.html >> $INDEX echo " " echo "Image Gallery Created Successfully" echo " " echo ""; #read -p "Hit RETURN to continue" temp