libvips/test/test_thumbnail.sh

72 lines
1.7 KiB
Bash
Raw Normal View History

2014-11-20 15:36:04 +01:00
#!/bin/sh
# resize a 1000x1000 image to every size in [100,1000], check for black
2014-11-20 15:36:04 +01:00
2018-09-21 18:05:47 +02:00
# see https://github.com/libvips/libvips/issues/131
2014-11-20 15:36:04 +01:00
# set -x
. ./variables.sh
2016-03-25 11:42:21 +01:00
# make a 1000x1000 mono test image ... add a bit so the image should not
# contain any zeros, helps to spot missing tiles and bad pixels
2014-11-20 15:36:04 +01:00
echo building test image ...
$vips extract_band $image $tmp/t1.v 1
$vips linear $tmp/t1.v $tmp/t2.v 1 20 --uchar
$vips replicate $tmp/t2.v $tmp/t1.v 4 4
$vips crop $tmp/t1.v $tmp/t2.v 10 10 1000 1000
2014-11-20 15:36:04 +01:00
# is a difference beyond a threshold? return 0 (meaning all ok) or 1 (meaning
# error, or outside threshold)
break_threshold() {
diff=$1
threshold=$2
return $(echo "$diff > $threshold" | bc -l)
}
2017-04-23 10:43:01 +02:00
# run the test with VIPS_STALL enabled to stress the seq system
export VIPS_STALL=1
size=1000
while [ $size -gt 99 ]; do
printf "testing size to $size ... "
$vipsthumbnail $tmp/t2.v -o $tmp/t1.v --size $size
if [ $($vipsheader -f width $tmp/t1.v) -ne $size ]; then
2016-03-25 11:42:21 +01:00
echo $tmp/t1.v failed -- bad size
echo output width is $($vipsheader -f width $tmp/t1.v)
exit
fi
if [ $($vipsheader -f height $tmp/t1.v) -ne $size ]; then
2016-03-25 11:42:21 +01:00
echo $tmp/t1.v failed -- bad size
echo output height is $($vipsheader -f width $tmp/t1.v)
exit
fi
$vips project $tmp/t1.v $tmp/cols.v $tmp/rows.v
min=$($vips min $tmp/cols.v)
if break_threshold $min 0; then
2016-03-25 11:42:21 +01:00
echo $tmp/t1.v failed -- has a black column
exit
fi
min=$($vips min $tmp/rows.v)
if break_threshold $min 0; then
2016-03-25 11:42:21 +01:00
echo $tmp/t1.v failed -- has a black row
exit
fi
min=$($vips min $tmp/t1.v)
2016-03-25 11:42:21 +01:00
if break_threshold $min 0; then
echo $tmp/t1.v failed -- has black pixels
exit
fi
echo ok
size=$(($size-1))
2014-11-20 15:36:04 +01:00
done
2014-11-20 15:36:04 +01:00