# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+set -f
+
VERSION="0.9.2"
if [[ -z $TITLE ]]; then
CONVERTTOOL="/usr/bin/convert"
fi
+if [[ -z $FINDCOMMAND ]]; then
+ FINDCOMMAND=/usr/bin/find
+fi
+
+if [[ -z $XARGSCOMMAND ]]; then
+ XARGSCOMMAND=/usr/bin/xargs
+fi
+
+if [[ -z $ECHOCOMMAND ]]; then
+ ECHOCOMMAND=/bin/echo
+fi
+
if [[ -z $WIDTH ]]; then
WIDTH=100
fi
+if [[ -z $IMAGEEXTENSIONS ]]; then
+ IMAGEEXTENSIONS="jpg gif png";
+fi
+
+FINDIMAGESOPTIONS=""
+
+for imageext in $IMAGEEXTENSIONS; do
+ FINDIMAGESOPTIONS=$FINDIMAGESOPTIONS' -o -type f -maxdepth 1 -iname '*.$imageext' -print0'
+done
+
+FINDIMAGESOPTIONS=${FINDIMAGESOPTIONS## -o }
+
usage() {
cat <<END
Usage:
cd "$1"
-if ( ! find . -name '*.jpg' -o -name '*.png' -o -name '*.gif' > /dev/null 2>/dev/null ); then
+if ( ! $FINDCOMMAND . $FINDIMAGESOPTIONS > /dev/null 2>/dev/null ); then
echo "$1 does not contain any images. Quitting."
exit 4
fi
exit 3
fi
-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/{}"
+$FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 --replace $CONVERTTOOL -resize $WIDTH '{}' 'icons/{}'
cat <<END > index.html
<?xml version="1.0"?>
END
-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
+$FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 --replace $ECHOCOMMAND {} |sort -g | sed -e 's#^./\(.*\)$#<div class="thumbnail"><a href="\1"><img src="icons/\1" /></a></div>#' >> index.html
cat <<END >> index.html
</body>
cd icons
-if ( ls *.jpg > /dev/null 2>/dev/null ); then
- TEMPMAX=$(identify *.jpg | sed -r 's#^.*?[0-9]+x([0-9]+)\+.*$#\1#' | sort -g -r | head -n 1)
- if [[ $TEMPMAX -gt $MAXHEIGHT ]]; then
- MAXHEIGHT=$TEMPMAX
- fi
-fi
-if ( ls *.gif > /dev/null 2>/dev/null ); then
- TEMPMAX=$(identify *.gif | sed -r 's#^.*?[0-9]+x([0-9]+)\+.*$#\1#' | sort -g -r | head -n 1)
-
- if [[ $TEMPMAX -gt $MAXHEIGHT ]]; then
- MAXHEIGHT=$TEMPMAX
+for imageext in $IMAGEEXTENSIONS; do
+ if ( ls "*.$imageext" > /dev/null 2>/dev/null ); then
+ TEMPMAX=$(identify *.jpg | grep "Geometry:" | sed -r 's#^.*Geometry:.*?[0-9]+x([0-9]+)\+.*$#\1#' | sort -g -r | head -n 1)
+ if [[ $TEMPMAX -gt $MAXHEIGHT ]]; then
+ MAXHEIGHT=$TEMPMAX
+ fi
fi
-fi
-
-if ( ls *.png > /dev/null 2>/dev/null ); then
- TEMPMAX=$(identify *.png | sed -r 's#^.*?[0-9]+x([0-9]+)\+.*$#\1#' | sort -g -r | head -n 1)
- if [[ $TEMPMAX -gt $MAXHEIGHT ]]; then
- MAXHEIGHT=$TEMPMAX
- fi
-fi
+done
cd ..
-
cat <<END > style.css