3 #########################################################################
4 # This program is free software: you can redistribute it and/or modify #
5 # it under the terms of the version 3 of the GNU General Public License #
6 # as published by the Free Software Foundation. #
8 # This program is distributed in the hope that it will be useful, but #
9 # WITHOUT ANY WARRANTY; without even the implied warranty of #
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
11 # General Public License for more details. #
13 # You should have received a copy of the GNU General Public License #
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
16 # Written by and Copyright (C) Francois Fleuret #
17 # Contact <francois@fleuret.org> for comments & bug reports #
18 #########################################################################
25 ######################################################################
26 # Create the directories
28 if [[ -z $1 ]] || [[ -z $2 ]]; then
29 echo "$0 <image directory> <result directory>"
33 if [[ ! -d $1 ]]; then
34 echo "Can not find directory $1"
38 mkdir $2 || error "Can not create $2."
39 mkdir $2/pics || error "Can not create $2/pics"
40 mkdir $2/thumbs || error "Can not create $2/thumbs"
42 ######################################################################
43 # Generate the html header
45 cat > $2/index.html <<EOF
46 <?xml version="1.0" encoding="iso-8859-1"?>
47 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
49 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
52 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
60 ######################################################################
61 # Generate the thumbnails, html content and copy the images
63 for i in $(find $1 -type f | sort); do
64 FILENAME=$(basename $i)
65 convert 2> /dev/null -geometry 180x120 $i $2/thumbs/${FILENAME}.jpg
67 if [[ $? == 0 ]]; then
68 echo "Copying ${FILENAME}"
69 cp $i $2/pics/${FILENAME}
70 echo "<a href=\"./pics/${FILENAME}\"><img src=\"./thumbs/${FILENAME}.jpg\" /></a>" >> $2/index.html
72 echo "Ignoring $i (not an image?)"
77 ######################################################################
78 # Generate the footer of the html file
80 cat >> $2/index.html <<EOF
86 ######################################################################