* Make the find command be built once and used several times
* add XARGSCOMMAND and a sensible default
* add ECHOCOMMAND and a sensible default
* sort the images in (general) numeric order before writing the HTML page
git-archimport-id: arch@sommitrealweird.co.uk--2005-desktop/bpgallery--mainline--0.9.2--patch-1
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
VERSION="0.9.2"
if [[ -z $TITLE ]]; then
VERSION="0.9.2"
if [[ -z $TITLE ]]; then
CONVERTTOOL="/usr/bin/convert"
fi
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 $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:
usage() {
cat <<END
Usage:
-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
echo "$1 does not contain any images. Quitting."
exit 4
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"?>
cat <<END > index.html
<?xml version="1.0"?>
-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>
cat <<END >> index.html
</body>
-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
-
-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