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
|
|
|
|
|
|
|
# see https://github.com/jcupitt/libvips/issues/131
|
|
|
|
|
|
|
|
# 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
|
2016-03-25 11:42:21 +01:00
|
|
|
vips linear $tmp/t1.v $tmp/t2.v 1 20 --uchar
|
|
|
|
vips replicate $tmp/t2.v $tmp/t1.v 2 2
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2016-03-25 07:11:01 +01:00
|
|
|
size=1000
|
|
|
|
while [ $size -gt 99 ]; do
|
|
|
|
printf "testing size to $size ... "
|
2016-03-25 11:42:21 +01:00
|
|
|
vipsthumbnail $tmp/t2.v -o $tmp/t1.v --size $size
|
|
|
|
if [ $(vipsheader -f width $tmp/t1.v) -ne $size ]; then
|
|
|
|
echo $tmp/t1.v failed -- bad size
|
|
|
|
echo output width is $(vipsheader -f width $tmp/t1.v)
|
2016-03-25 07:11:01 +01:00
|
|
|
exit
|
|
|
|
fi
|
2016-03-25 11:42:21 +01:00
|
|
|
if [ $(vipsheader -f height $tmp/t1.v) -ne $size ]; then
|
|
|
|
echo $tmp/t1.v failed -- bad size
|
|
|
|
echo output height is $(vipsheader -f width $tmp/t1.v)
|
2016-03-25 07:11:01 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2016-03-25 11:42:21 +01:00
|
|
|
vips project $tmp/t1.v $tmp/cols.v $tmp/rows.v
|
2016-03-25 07:11:01 +01:00
|
|
|
|
|
|
|
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
|
2016-03-25 07:11:01 +01:00
|
|
|
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)
|
|
|
|
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
|
|
|
|
|
|
|
|