mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
added support for smaller than target previews...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
3a32bb883e
commit
fd9d8539e1
@ -188,9 +188,21 @@ makepreview(){
|
|||||||
# calculate the factor...
|
# calculate the factor...
|
||||||
FACTOR=$(echo "scale = 4; if($H > $W) s = $H else s = $W ; s / $SIZE" | bc -l)
|
FACTOR=$(echo "scale = 4; if($H > $W) s = $H else s = $W ; s / $SIZE" | bc -l)
|
||||||
|
|
||||||
echo "($FACTOR): ${OUT}:${COMPRESSION}"
|
# 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)
|
||||||
|
|
||||||
vips im_shrink "./$IN" "./${OUT}:${COMPRESSION}" $FACTOR $FACTOR 2> /dev/null
|
# 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}"
|
touch -c -r "./$IN" "./${OUT}"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user