Skip to content
Snippets Groups Projects
Commit c61dcebf authored by Toke Eskildsen's avatar Toke Eskildsen
Browse files

Further improvements to optional force regeneration

parent b3dca271
No related branches found
No related tags found
No related merge requests found
...@@ -218,18 +218,22 @@ function makeImageParams() { ...@@ -218,18 +218,22 @@ function makeImageParams() {
# If force is true and image does not exist, true is returned # If force is true and image does not exist, true is returned
# If force is false and image exists, false is returned # If force is false and image exists, false is returned
# If force is false and image does not exists, true is returned # If force is false and image does not exists, true is returned
# Input: force image # Input: force image designation
# Output: true/false. Use with 'if should_generate true dummy; then' # Output: true/false. Use with 'if shouldGenerate true dummy; then'
should_generate() { shouldGenerate() {
local FORCE="$1" local FORCE="$1"
local IMG="$2" local IMG="$2"
local DES="$3"
if [ "true" == "$FORCE" -a -e "$IMG" ]; then if [ ".true" == ".$FORCE" -a -e "$IMG" ]; then
rm -rf "$IMG" rm -rf "$IMG"
fi fi
if [ ! -e "$IMG" -a "." != ".$DES" ]; then
echo " - ${IMG##*/} ($DES)"
fi
[ ! -e "$IMG" ] [ ! -e "$IMG" ]
} }
export -f should_generate export -f shouldGenerate
# Creates a presentation image and a histogram for the given image # Creates a presentation image and a histogram for the given image
# srcFolder dstFolder image crop presentation_script tile # srcFolder dstFolder image crop presentation_script tile
...@@ -265,8 +269,7 @@ function makeImages() { ...@@ -265,8 +269,7 @@ function makeImages() {
# Even if TILE="true", we create the full main presentational image as it # Even if TILE="true", we create the full main presentational image as it
# might be requested for download # might be requested for download
if should_generate "$FORCE_QAIMAGE" "$DEST_IMAGE"; then if shouldGenerate "$FORCE_QAIMAGE" "$DEST_IMAGE" "QA"; then
echo " - ${DEST_IMAGE##*/}"
gm convert "$SOURCE_IMAGE" -quality $IMAGE_DISP_QUALITY "$DEST_IMAGE" gm convert "$SOURCE_IMAGE" -quality $IMAGE_DISP_QUALITY "$DEST_IMAGE"
fi fi
...@@ -277,34 +280,26 @@ function makeImages() { ...@@ -277,34 +280,26 @@ function makeImages() {
local CONV="$SRC_IMAGE" local CONV="$SRC_IMAGE"
fi fi
if should_generate "$FORCE_TILES" "$TILE_FOLDER"; then if shouldGenerate "$FORCE_TILES" "$TILE_FOLDER" "tiles"; then
echo " - ${TILE_FOLDER##*/} (deepzoom)"
# TODO: Specify JPEG quality # TODO: Specify JPEG quality
deepzoom "$CONV" -format $IMAGE_DISP_EXT -path "${DEST_FOLDER}/" deepzoom "$CONV" -format $IMAGE_DISP_EXT -path "${DEST_FOLDER}/"
fi fi
if should_generate "$FORCE_BLOWN" "$WHITE_IMAGE"; then if shouldGenerate "$FORCE_BLOWN" "$WHITE_IMAGE" "overlay"; then
echo " - ${WHITE_IMAGE##*/}"
gm convert "$CONV" -black-threshold 255,255,255 -white-threshold 254,254,254 -negate -fill \#FF0000 -opaque black -transparent white -colors 2 "$WHITE_IMAGE" gm convert "$CONV" -black-threshold 255,255,255 -white-threshold 254,254,254 -negate -fill \#FF0000 -opaque black -transparent white -colors 2 "$WHITE_IMAGE"
fi fi
if should_generate "$FORCE_BLOWN" "$BLACK_IMAGE"; then if shouldGenerate "$FORCE_BLOWN" "$BLACK_IMAGE" "overlay"; then
echo " - ${BLACK_IMAGE##*/}"
gm convert "$CONV" -black-threshold 1,1,1 -white-threshold 0,0,0 -fill \#0000FF -opaque black -transparent white -colors 2 "$BLACK_IMAGE" gm convert "$CONV" -black-threshold 1,1,1 -white-threshold 0,0,0 -fill \#0000FF -opaque black -transparent white -colors 2 "$BLACK_IMAGE"
fi fi
if [ "true" == "$FORCE_PRESENTATION" -a -f "$PRESENTATION_IMAGE" ]; then if shouldGenerate "$FORCE_PRESENTATION" "$PRESENTATION_IMAGE" "presentation"; then
rm -f "$PRESENTATION_IMAGE"
fi
if [ ! -f $PRESENTATION_IMAGE ]; then
echo " - ${PRESENTATION_IMAGE##*/}"
$PRESENTATION_SCRIPT "$CONV" "$PRESENTATION_IMAGE" $PRESENTATION_SCRIPT "$CONV" "$PRESENTATION_IMAGE"
fi fi
if should_generate "$FORCE_HISTOGRAM" "$HIST_IMAGE"; then if shouldGenerate "$FORCE_HISTOGRAM" "$HIST_IMAGE" "histogram"; then
# Remove "-separate -append" to generate a RGB histogram # Remove "-separate -append" to generate a RGB histogram
# http://www.imagemagick.org/Usage/files/#histogram # http://www.imagemagick.org/Usage/files/#histogram
echo " - ${HIST_IMAGE##*/}"
if [ "." == ".$CROP_PERCENT" ]; then if [ "." == ".$CROP_PERCENT" ]; then
convert "$CONV" -separate -append -define histogram:unique-colors=false -write histogram:mpr:hgram +delete mpr:hgram -negate -strip "$HIST_IMAGE" convert "$CONV" -separate -append -define histogram:unique-colors=false -write histogram:mpr:hgram +delete mpr:hgram -negate -strip "$HIST_IMAGE"
else else
...@@ -312,8 +307,7 @@ function makeImages() { ...@@ -312,8 +307,7 @@ function makeImages() {
fi fi
fi fi
if should_generate "$FORCE_THUMBNAILS" "$THUMB_IMAGE"; then if shouldGenerate "$FORCE_THUMBNAILS" "$THUMB_IMAGE" "thumbnail"; then
echo " - ${THUMB_IMAGE##*/}"
gm convert "$CONV" -sharpen 3 -enhance -resize $THUMB_IMAGE_SIZE "$THUMB_IMAGE" gm convert "$CONV" -sharpen 3 -enhance -resize $THUMB_IMAGE_SIZE "$THUMB_IMAGE"
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment