]> git.sommitrealweird.co.uk Git - bpgallery.git/blobdiff - bpgallery.sh
Add a very rough progress meter
[bpgallery.git] / bpgallery.sh
index 3d82851af18eda185945a7ef19878a06875483cb..a088ebfed5a51c4fb0a97c44a1b00fed70858d33 100755 (executable)
@@ -26,27 +26,31 @@ if [[ -z $TITLE ]]; then
 fi
 
 if [[ -z $CONVERTTOOL ]]; then
 fi
 
 if [[ -z $CONVERTTOOL ]]; then
-       CONVERTTOOL="/usr/bin/convert"
+       CONVERTTOOL=convert
 fi
 
 if [[ -z $FINDCOMMAND ]]; then
 fi
 
 if [[ -z $FINDCOMMAND ]]; then
-       FINDCOMMAND=/usr/bin/find
+       FINDCOMMAND=find
 fi
 
 if [[ -z $XARGSCOMMAND ]]; then
 fi
 
 if [[ -z $XARGSCOMMAND ]]; then
-       XARGSCOMMAND=/usr/bin/xargs
+       XARGSCOMMAND=xargs
 fi
 
 if [[ -z $ECHOCOMMAND ]]; then
 fi
 
 if [[ -z $ECHOCOMMAND ]]; then
-       ECHOCOMMAND=/bin/echo
+       ECHOCOMMAND=echo
 fi
 
 if [[ -z $SORTCOMMAND ]]; then
 fi
 
 if [[ -z $SORTCOMMAND ]]; then
-       SORTCOMMAND=/usr/bin/sort
+       SORTCOMMAND=sort
 fi
 
 if [[ -z $IDENTIFYCOMMAND ]]; then
 fi
 
 if [[ -z $IDENTIFYCOMMAND ]]; then
-       IDENTIFYCOMMAND=/usr/bin/identify
+       IDENTIFYCOMMAND=identify
+fi
+
+if [[ -z $HEADCOMMAND ]]; then
+       HEADCOMMAND=head
 fi
 
 if [[ -z $WIDTH ]]; then
 fi
 
 if [[ -z $WIDTH ]]; then
@@ -57,6 +61,10 @@ if [[ -z $IMAGEEXTENSIONS ]]; then
        IMAGEEXTENSIONS="jpeg jpg gif png";
 fi
 
        IMAGEEXTENSIONS="jpeg jpg gif png";
 fi
 
+if [[ -z $WCCOMMAND ]]; then
+       WCCOMMAND="wc -l"
+fi
+
 FINDIMAGESOPTIONS=""
 
 for imageext in $IMAGEEXTENSIONS; do
 FINDIMAGESOPTIONS=""
 
 for imageext in $IMAGEEXTENSIONS; do
@@ -120,7 +128,12 @@ else
        exit 3
 fi
 
        exit 3
 fi
 
-$FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 --replace $CONVERTTOOL -resize $WIDTH '{}' 'icons/{}'
+totalimages=$($FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 --replace echo {} | $WCCOMMAND);
+currentimage=0
+
+$FINDCOMMAND . $FINDIMAGESOPTIONS | $XARGSCOMMAND -0 --verbose --max-procs=4 --replace $CONVERTTOOL -resize $WIDTH '{}' 'icons/{}' 2>&1 | while read throwout; do echo done: $currentimage/$totalimages images; currentimage=$((currentimage+1)); done
+
+echo done: $totalimages/$totalimages images
 
 cat <<END > index.html
 <?xml version="1.0"?>
 
 cat <<END > index.html
 <?xml version="1.0"?>
@@ -146,7 +159,7 @@ cd icons
 
 for imageext in $IMAGEEXTENSIONS; do
        if ( ls "*.$imageext" > /dev/null 2>/dev/null ); then
 
 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)
+               TEMPMAX=$($IDENTIFYCOMMAND *.$imageext | grep "Geometry:" | sed -r 's#^.*Geometry:.*?[0-9]+x([0-9]+)\+.*$#\1#' | $SORTCOMMAND -g -r | $HEADCOMMAND -n 1)
                if [[ $TEMPMAX -gt $MAXHEIGHT ]]; then
                        MAXHEIGHT=$TEMPMAX
                fi
                if [[ $TEMPMAX -gt $MAXHEIGHT ]]; then
                        MAXHEIGHT=$TEMPMAX
                fi