* Simple Justified Gallery
       
   URI git clone git://git.codevoid.de/mkpicindex
   DIR Log
   DIR Files
   DIR Refs
   DIR README
       ---
   DIR commit fc32da5f774e4e54895562c4d336495149b5177a
   DIR parent 209afeae9c5d3c0e521f7622c756822b78a6cb75
   URI Author: Stefan Hagen <sh+git[at]codevoid[dot]de>
       Date:   Sat, 26 Oct 2019 15:54:58 +0200
       
       Add background process
       
       Diffstat:
         M mkpicindex-static.sh                |      48 +++++++++++++++++++++++--------
       
       1 file changed, 36 insertions(+), 12 deletions(-)
       ---
   DIR diff --git a/mkpicindex-static.sh b/mkpicindex-static.sh
       @@ -59,6 +59,12 @@ get_height_by_width() {
            debug "get_height_by_width: FILE=$F TARGET_WIDTH=$TW FILE_WxH=$WH RET_HEIGHT=$R"
        }
        
       +bg_check() { 
       +    T=$(pgrep convert | wc -l | awk '{ print $1 }');
       +    debug "Threads: $T";
       +    printf "$T"
       +}
       +
        # CREATE THUMBNAIL
        create_thumb() {
            # $F - original
       @@ -72,18 +78,36 @@ create_thumb() {
            if ! [ -f "$THUMB_PATH/$T.gif" ] || [ -f "$THUMB_PATH/$T.jpeg" ];
            then
                case $(printf '%s' "${F##*.}" | tr '[:upper:]' '[:lower:]') in
       -            gif) console "Creating Thumbnail: $THUMB_PATH/$T.gif"
       -                 convert -quality $THUMB_QUALITY -sharpen 2x2 \
       -                         -coalesce -resize 6000x$H\> \
       -                         -deconstruct "$F" \
       -                         "$THUMB_PATH/${T}_tmp.gif" && \
       -                 mv "$THUMB_PATH/${T}_tmp.gif" "$THUMB_PATH/$T.gif"
       -                printf '%s' "$THUMB_PATH/$T.gif" ;;
       -            *)   convert -quality $THUMB_QUALITY -sharpen 2x2 \
       -                         -resize 6000x$H\> "$F" \
       -                         "$THUMB_PATH/${T}_tmp.jpeg" && \
       -                 mv "$THUMB_PATH/${T}_tmp.jpeg" "$THUMB_PATH/$T.jpeg"
       -                printf '%s' "$THUMB_PATH/$T.jpeg" ;;
       +            gif) if [ "$(bg_check)" -gt "4" ]; then
       +                    console "Creating Thumbnail (FG): $THUMB_PATH/$T.gif"
       +                    convert -quality $THUMB_QUALITY -sharpen 2x2 \
       +                            -coalesce -resize 6000x$H\> \
       +                            -deconstruct "$F" \
       +                            "$THUMB_PATH/${T}_tmp.gif" && \
       +                    mv "$THUMB_PATH/${T}_tmp.gif" "$THUMB_PATH/$T.gif"
       +                 else
       +                    console "Creating Thumbnail (BG): $THUMB_PATH/$T.gif"
       +                    convert -quality $THUMB_QUALITY -sharpen 2x2 \
       +                            -coalesce -resize 6000x$H\> \
       +                            -deconstruct "$F" \
       +                            "$THUMB_PATH/${T}_tmp.gif" && \
       +                    mv "$THUMB_PATH/${T}_tmp.gif" "$THUMB_PATH/$T.gif" &
       +                 fi
       +                 printf '%s' "$THUMB_PATH/$T.gif" ;;
       +             *)   if [ "$(bg_check)" -gt "4" ]; then
       +                    console "Creating Thumbnail (FG): $THUMB_PATH/$T.jpeg"
       +                    convert -quality $THUMB_QUALITY -sharpen 2x2 \
       +                             -resize 6000x$H\> "$F" \
       +                             "$THUMB_PATH/${T}_tmp.jpeg" && \
       +                    mv "$THUMB_PATH/${T}_tmp.jpeg" "$THUMB_PATH/$T.jpeg"
       +                 else
       +                    console "Creating Thumbnail (BG): $THUMB_PATH/$T.jpeg"
       +                    convert -quality $THUMB_QUALITY -sharpen 2x2 \
       +                             -resize 6000x$H\> "$F" \
       +                             "$THUMB_PATH/${T}_tmp.jpeg" && \
       +                    mv "$THUMB_PATH/${T}_tmp.jpeg" "$THUMB_PATH/$T.jpeg" &
       +                 fi
       +                 printf '%s' "$THUMB_PATH/$T.jpeg" ;;
                esac
            fi
        }