X-Git-Url: https://git.sommitrealweird.co.uk/bpgallery.git/blobdiff_plain/104efc9eed8f557a3a92f6fc1dd10913b71ff4aa..0bb2d087e1a6e4faae87f028f454c278827d2a6d:/bpgallery.sh diff --git a/bpgallery.sh b/bpgallery.sh index 63a27e8..3d82851 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,42 @@ 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 $SORTCOMMAND ]]; then + SORTCOMMAND=/usr/bin/sort +fi + +if [[ -z $IDENTIFYCOMMAND ]]; then + IDENTIFYCOMMAND=/usr/bin/identify +fi + if [[ -z $WIDTH ]]; then WIDTH=100 fi +if [[ -z $IMAGEEXTENSIONS ]]; then + IMAGEEXTENSIONS="jpeg 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 +120,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 +134,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 {} |$SORTCOMMAND -g | sed -e 's#^./\(.*\)$#
#' >> index.html cat <> index.html @@ -109,30 +143,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=$($IDENTIFYCOMMAND *.$imageext | grep "Geometry:" | sed -r 's#^.*Geometry:.*?[0-9]+x([0-9]+)\+.*$#\1#' | $SORTCOMMAND -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