2014-11-20 15:36:04 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2016-03-25 07:11:01 +01:00
|
|
|
# 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 ...
|
2016-05-09 00:48:37 +02:00
|
|
|
$vips extract_band $image $tmp/t1.v 1
|
|
|
|
$vips linear $tmp/t1.v $tmp/t2.v 1 20 --uchar
|
2022-03-11 17:21:12 +01:00
|
|
|
$vips replicate $tmp/t2.v $tmp/t1.v 4 4
|
2016-05-09 00:48:37 +02:00
|
|
|
$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
|
|
|
|
|
2016-03-25 07:11:01 +01:00
|
|
|
size=1000
|
|
|
|
while [ $size -gt 99 ]; do
|
|
|
|
printf "testing size to $size ... "
|
2016-05-09 00:48:37 +02:00
|
|
|
$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
|
2016-05-09 00:48:37 +02:00
|
|
|
echo output width is $($vipsheader -f width $tmp/t1.v)
|
2016-03-25 07:11:01 +01:00
|
|
|
exit
|
|
|
|
fi
|
2016-05-09 00:48:37 +02:00
|
|
|
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
|
2016-05-09 00:48:37 +02:00
|
|
|
echo output height is $($vipsheader -f width $tmp/t1.v)
|
2016-03-25 07:11:01 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2016-05-09 00:48:37 +02:00
|
|
|
$vips project $tmp/t1.v $tmp/cols.v $tmp/rows.v
|
2016-03-25 07:11:01 +01:00
|
|
|
|
2016-05-09 00:48:37 +02:00
|
|
|
min=$($vips min $tmp/cols.v)
|
2016-03-25 07:11:01 +01:00
|
|
|
if break_threshold $min 0; then
|
2016-03-25 11:42:21 +01:00
|
|
|
echo $tmp/t1.v failed -- has a black column
|
2016-03-25 07:11:01 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2016-05-09 00:48:37 +02:00
|
|
|
min=$($vips min $tmp/rows.v)
|
2016-03-25 07:11:01 +01:00
|
|
|
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
|
|
|
|
|
2016-05-09 00:48:37 +02:00
|
|
|
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
|
2016-03-25 07:11:01 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ok
|
|
|
|
|
|
|
|
size=$(($size-1))
|
2014-11-20 15:36:04 +01:00
|
|
|
done
|
2016-03-25 07:11:01 +01:00
|
|
|
|
2014-11-20 15:36:04 +01:00
|
|
|
|
|
|
|
|