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

Optimization: Slightly faster image size lookup

parent c47a583f
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,13 @@ if [ "." == ".$ASSUME_GREY" ]; then
ASSUME_GREY=true
fi
# Prints width and height of the given image, separated by space
# Input: Image
function isize() {
identify -format "%w %h" "$1"
}
export -f isize
# TODO: Accept destination for identify-file as input
# TODO: If FORCE_HISTOGRAM is true, cached identify-files should be deleted
# to ensure CROP_PERCENT is used
......@@ -59,6 +66,7 @@ function im_identify() {
}
export -f im_identify
# TODO: Accept destination for grey-stats-file as input
# Input: image
......
......@@ -288,21 +288,27 @@ function makePreviewPage() {
exit
fi
local IDENTIFY=`identify "$DEST_IMAGE" | grep -o " [0-9]\+x[0-9]\\+ "`
IMAGE_WIDTH=`echo $IDENTIFY | grep -o "[0-9]\+x" | grep -o "[0-9]\+"`
IMAGE_HEIGHT=`echo $IDENTIFY | grep -o "x[0-9]\+" | grep -o "[0-9]\+"`
set -- junk `isize "$DEST_IMAGE"`
shift
IMAGE_WIDTH=$1
IMAGE_HEIGHT=$2
IMAGE_MP=`echo "scale=1;x=$IMAGE_WIDTH*$IMAGE_HEIGHT/1000000; if(x<1) print 0; x" | bc`
local TIDENTIFY=`identify "$THUMB_IMAGE" | grep -o " [0-9]\+x[0-9]\\+ "`
THUMB_WIDTH=`echo $TIDENTIFY | grep -o "[0-9]\+x" | grep -o "[0-9]\+"`
THUMB_HEIGHT=`echo $TIDENTIFY | grep -o "x[0-9]\+" | grep -o "[0-9]\+"`
local HIDENTIFY=`identify "$HIST_IMAGE" | grep -o " [0-9]\+x[0-9]\\+ "`
HISTOGRAM_WIDTH=`echo $HIDENTIFY | grep -o "[0-9]\+x" | grep -o "[0-9]\+"`
HISTOGRAM_HEIGHT=`echo $HIDENTIFY | grep -o "x[0-9]\+" | grep -o "[0-9]\+"`
set -- junk `isize "$THUMB_IMAGE"`
shift
THUMB_WIDTH=$1
THUMB_HEIGHT=$2
set -- junk `isize "$HIST_IMAGE"`
shift
HISTOGRAM_WIDTH=$1
HISTOGRAM_HEIGHT=$2
if [ ".true" == ".$PRESENTATION" ]; then
local PIDENTIFY=`identify "$PRESENTATION_IMAGE" | grep -o " [0-9]\+x[0-9]\\+ "`
PRESENTATION_WIDTH=`echo $PIDENTIFY | grep -o "[0-9]\+x" | grep -o "[0-9]\+"`
PRESENTATION_HEIGHT=`echo $PIDENTIFY | grep -o "x[0-9]\+" | grep -o "[0-9]\+"`
set -- junk `isize "$PRESENTATION_IMAGE"`
shift
PRESENTATION_WIDTH=$1
PRESENTATION_HEIGHT=$2
fi
local CREATED_PAGES=`addGetCounter $PAGE_COUNTER`
......
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