From 43d71fd6787282ce8b3e49e08c1e6d0b0c8c03c0 Mon Sep 17 00:00:00 2001
From: Toke Eskildsen <te@ekot.dk>
Date: Thu, 19 Sep 2013 23:03:21 +0200
Subject: [PATCH] Added generation of blown high- and low-lights overlays for
 thumbs

---
 quack.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/quack.sh b/quack.sh
index ac07669..2bff434 100755
--- a/quack.sh
+++ b/quack.sh
@@ -83,7 +83,10 @@ export FORCE_QAIMAGE=false
 # If true, thumbnails will be generated even if they already exists.
 export FORCE_THUMBNAILS=false
 # If true, blown high- and low-light overlays will be generated even if they already exists.
+# Setting this to true will also set FORCE_BLOWN_THUMBS to true
 export FORCE_BLOWN=false
+# If true, blown high- and low-light overlays for thumbs will be generated even if they already exists.
+export FORCE_BLOWN_THUMBS=false
 # If true, presentation images will be generated even if they already exists.
 export FORCE_PRESENTATION=false
 # If true, histogram images will be generated even if they already exists.
@@ -123,6 +126,11 @@ if [ -e "quack.settings" ]; then
 fi
 popd > /dev/null
 
+if [ ".true" == ".$FORCE_BLOWN" ]; then
+    # When we force regeneration of blown, we myst also regenerate the blown thumbs.
+    export FORCE_BLOWN_THUMBS=true
+fi
+
 PRESENTATION_SCRIPT="$ROOT/presentation.sh"
 FOLDER_TEMPLATE="$ROOT/folder_template.html"
 IMAGE_TEMPLATE="$ROOT/image_template.html"
@@ -259,6 +267,8 @@ function makeImages() {
     local THUMB_IMAGE="${DEST_FOLDER}/${BASE}.thumb.jpg"
     local WHITE_IMAGE="${DEST_FOLDER}/${BASE}.white.png"
     local BLACK_IMAGE="${DEST_FOLDER}/${BASE}.black.png"
+    local THUMB_OVERLAY_WHITE="${DEST_FOLDER}/${BASE}.white.thumb.png"
+    local THUMB_OVERLAY_BLACK="${DEST_FOLDER}/${BASE}.black.thumb.png"
     local PRESENTATION_IMAGE="${DEST_FOLDER}/${BASE}.presentation.jpg"
     local TILE_FOLDER="${DEST_FOLDER}/${BASE}_files"
 
@@ -311,6 +321,19 @@ function makeImages() {
         gm convert "$CONV" -sharpen 3 -enhance -resize $THUMB_IMAGE_SIZE "$THUMB_IMAGE"
     fi
 
+    if shouldGenerate "$FORCE_BLOWN_THUMBS" "$THUMB_OVERLAY_WHITE" "thumb overlay"; then
+        echo " - ${THUMB_OVERLAY_WHITE##*/}"
+        # Note: We use ImageMagick here as older versions of GraphicsMagic does not
+        # handle resizing of alpha-channel PNGs followed by color reduction
+        convert "$WHITE_IMAGE" -resize $THUMB_IMAGE_SIZE -colors 2 "$THUMB_OVERLAY_WHITE"
+    fi
+    if shouldGenerate "$FORCE_BLOWN_THUMBS" "$THUMB_OVERLAY_BLACK" "thumb overlay"; then
+        echo " - ${THUMB_OVERLAY_BLACK##*/}"
+        # Note: We use ImageMagick here as older versions of GraphicsMagic does not
+        # handle resizing of alpha-channel PNGs followed by color reduction
+        convert "$BLACK_IMAGE" -resize $THUMB_IMAGE_SIZE -colors 2 "$THUMB_OVERLAY_BLACK"
+    fi
+
 }
 
 # Generates overlays for the stated block and updates idnext & idprev
-- 
GitLab