added support for smaller than target previews...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-09-17 02:56:20 +03:00
parent 3a32bb883e
commit fd9d8539e1

View File

@ -188,9 +188,21 @@ makepreview(){
# calculate the factor...
FACTOR=$(echo "scale = 4; if($H > $W) s = $H else s = $W ; s / $SIZE" | bc -l)
# NOTE: bash does not do float comparisons so we cheat again ;)
TOO_SMALL=$(echo "if($FACTOR <= 1) s = 1 else s = 0 ; s" | bc -l)
# the input is smaller than target size, copy as-is...
if [[ $TOO_SMALL == 1 ]] ; then
echo "$IN: Too small, copying as-is..."
cp "./$IN" "./$OUT"
# shrink...
else
echo "($FACTOR): ${OUT}:${COMPRESSION}"
vips im_shrink "./$IN" "./${OUT}:${COMPRESSION}" $FACTOR $FACTOR 2> /dev/null
fi
touch -c -r "./$IN" "./${OUT}"