From: Brett Parker Date: Tue, 25 Jan 2005 22:37:04 +0000 (+0000) Subject: Make more configurable for different paths for external programs X-Git-Tag: release-0.9.3~9 X-Git-Url: https://git.sommitrealweird.co.uk/bpgallery.git/commitdiff_plain/cdb23c0adbd2286f0aec1d8b269621fecd1420d5?ds=sidebyside Make more configurable for different paths for external programs * 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 --- diff --git a/bpgallery.sh b/bpgallery.sh index 63a27e8..d95049e 100755 --- a/bpgallery.sh +++ b/bpgallery.sh @@ -17,6 +17,8 @@ # 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 @@ -27,10 +29,34 @@ if [[ -z $CONVERTTOOL ]]; 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 < /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 @@ -86,7 +112,7 @@ else 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 < index.html @@ -100,7 +126,7 @@ cat < index.html 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#^./\(.*\)$#
#' >> index.html +$FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 --replace $ECHOCOMMAND {} |sort -g | sed -e 's#^./\(.*\)$#
#' >> index.html cat <> index.html @@ -109,30 +135,17 @@ END 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 < style.css