3 # makegallery.sh - builds a simple 'gallery' from a collection of images
4 # Copyright (C) 2004 Brett Parker <iDunno@sommitrealweird.co.uk>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 if [[ -z $TITLE ]]; then
26 if [[ -z $CONVERTTOOL ]]; then
27 CONVERTTOOL="/usr/bin/convert"
30 if [[ -z $WIDTH ]]; then
37 $0 [--help|--version|<path to images>]
40 displays this help screen
42 displays the version and exits
59 if [[ "$1" == "--help" || "$1" == "-h" ]]; then
64 if [[ "$1" == "--version" || "$1" == "-v" ]]; then
69 if [[ ! -d $1 ]]; then
70 echo "$1 is not a directory"
77 if ( ! find . -name '*.jpg' -o -name '*.png' -o -name '*.gif' > /dev/null 2>/dev/null ); then
78 echo "$1 does not contain any images. Quitting."
82 if [ ! -d icons ]; then
85 echo "$1 already contains an icons folder, stopping"
89 find . -type f -name \*.jpg -print0 -or -type f -name \*.gif -print0 -or -type f -name \*.png -print0 -maxdepth 1 | xargs -0 --replace $CONVERTTOOL -resize $WIDTH "{}" "icons/{}"
91 cat <<END > index.html
93 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">
94 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
96 <title>${TITLE}</title>
97 <link rel="stylesheet" href="style.css" type="text/css" />
103 find . -type f -name \*.jpg -maxdepth 1 -print -or -type f -name \*.gif -maxdepth 1 -print -or -type f -name \*.png -maxdepth 1 -print | sed -e 's#^./\(.*\)$#<div class="thumbnail"><a href="\1"><img src="icons/\1" /></a></div>#' >> index.html
105 cat <<END >> index.html
112 if ( ls *.jpg > /dev/null 2>/dev/null ); then
113 TEMPMAX=$(identify *.jpg | sed -r 's#^.*?[0-9]+x([0-9]+)\+.*$#\1#' | sort -g -r | head -n 1)
114 if [[ $TEMPMAX -gt $MAXHEIGHT ]]; then
119 if ( ls *.gif > /dev/null 2>/dev/null ); then
120 TEMPMAX=$(identify *.gif | sed -r 's#^.*?[0-9]+x([0-9]+)\+.*$#\1#' | sort -g -r | head -n 1)
122 if [[ $TEMPMAX -gt $MAXHEIGHT ]]; then
127 if ( ls *.png > /dev/null 2>/dev/null ); then
128 TEMPMAX=$(identify *.png | sed -r 's#^.*?[0-9]+x([0-9]+)\+.*$#\1#' | sort -g -r | head -n 1)
129 if [[ $TEMPMAX -gt $MAXHEIGHT ]]; then
138 cat <<END > style.css
142 font-family: sans-serif;
151 height: ${MAXHEIGHT}px;