add the test_thumbnail script too
This commit is contained in:
parent
fcc790f6c0
commit
3d1469179c
@ -1,8 +1,17 @@
|
||||
|
||||
EXTRA_DIST = \
|
||||
images \
|
||||
variables.sh.in
|
||||
variables.sh.in \
|
||||
test_cli.sh \
|
||||
test_formats.sh \
|
||||
test_seq.sh \
|
||||
test_thumbnail.sh \
|
||||
test_threading.sh \
|
||||
test_arithmetic.py \
|
||||
test_colour.py \
|
||||
test_conversion.py
|
||||
|
||||
# don't run test_thumbnail.sh by default, it takes ages
|
||||
TESTS = \
|
||||
test_cli.sh \
|
||||
test_formats.sh \
|
||||
@ -12,3 +21,7 @@ TESTS = \
|
||||
test_colour.py \
|
||||
test_conversion.py
|
||||
|
||||
clean-local:
|
||||
-rm -rf tmp
|
||||
-rm -f *.pyc
|
||||
|
||||
|
@ -40,8 +40,6 @@ save_load() {
|
||||
|
||||
# is a difference beyond a threshold? return 0 (meaning all ok) or 1 (meaning
|
||||
# error, or outside threshold)
|
||||
#
|
||||
# use bc since bash does not support fp math
|
||||
break_threshold() {
|
||||
diff=$1
|
||||
threshold=$2
|
||||
@ -56,7 +54,7 @@ test_difference() {
|
||||
|
||||
vips subtract $before $after $tmp/difference.v
|
||||
vips abs $tmp/difference.v $tmp/abs.v
|
||||
dif=`vips max $tmp/abs.v`
|
||||
dif=$(vips max $tmp/abs.v)
|
||||
|
||||
if break_threshold $dif $threshold; then
|
||||
echo "save / load difference is $dif"
|
||||
@ -106,9 +104,9 @@ test_raw() {
|
||||
echo -n "testing $(basename $in) raw ... "
|
||||
|
||||
vips copy $in $tmp/before.v
|
||||
width=`vipsheader -f Xsize $tmp/before.v`
|
||||
height=`vipsheader -f Ysize $tmp/before.v`
|
||||
bands=`vipsheader -f Bands $tmp/before.v`
|
||||
width=$(vipsheader -f width $tmp/before.v)
|
||||
height=$(vipsheader -f height $tmp/before.v)
|
||||
bands=$(vipsheader -f bands $tmp/before.v)
|
||||
|
||||
vips rawsave $tmp/before.v $tmp/raw
|
||||
vips rawload $tmp/raw $tmp/after.v $width $height $bands
|
||||
|
@ -2,14 +2,12 @@
|
||||
|
||||
# set -x
|
||||
|
||||
source variables.sh
|
||||
. ./variables.sh
|
||||
|
||||
chain=1
|
||||
|
||||
# im_benchmark needs a labq
|
||||
vips im_sRGB2XYZ $image $tmp/t1.v
|
||||
vips im_XYZ2Lab $tmp/t1.v $tmp/t2.v
|
||||
vips im_Lab2LabQ $tmp/t2.v $tmp/t3.v
|
||||
vips colourspace $image $tmp/t3.v labq
|
||||
|
||||
for tile in 10 64 128 512; do
|
||||
# benchmark includes a dither which will vary with tile size
|
||||
@ -22,9 +20,9 @@ for tile in 10 64 128 512; do
|
||||
vips --vips-concurrency=$cpus \
|
||||
--vips-tile-width=$tile --vips-tile-height=$tile \
|
||||
im_benchmarkn $tmp/t3.v $tmp/t7.v $chain
|
||||
vips im_subtract $tmp/t5.v $tmp/t7.v $tmp/t8.v
|
||||
vips im_abs $tmp/t8.v $tmp/t9.v
|
||||
max=`vips im_max $tmp/t9.v`
|
||||
vips subtract $tmp/t5.v $tmp/t7.v $tmp/t8.v
|
||||
vips abs $tmp/t8.v $tmp/t9.v
|
||||
max=$(vips max $tmp/t9.v)
|
||||
if [ $max -gt 0 ]; then
|
||||
break
|
||||
fi
|
||||
|
60
test/test_thumbnail.sh
Executable file
60
test/test_thumbnail.sh
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
|
||||
# resize a 1000x1000 image to every size in [500,1000] with every interpolator
|
||||
# and check for black lines
|
||||
|
||||
# see https://github.com/jcupitt/libvips/issues/131
|
||||
|
||||
# set -x
|
||||
|
||||
. ./variables.sh
|
||||
|
||||
# make a 1000x1000 mono test image
|
||||
echo building test image ...
|
||||
vips extract_band $image $tmp/t1.v 1
|
||||
vips replicate $tmp/t1.v $tmp/t2.v 2 2
|
||||
vips extract_area $tmp/t2.v $tmp/t1.v 10 10 1000 1000
|
||||
|
||||
# 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)
|
||||
}
|
||||
|
||||
for interp in nearest bilinear bicubic lbb nohalo vsqbs; do
|
||||
size=1000
|
||||
while [ $size -gt 499 ]; do
|
||||
echo -n "testing $interp, size to $size ... "
|
||||
vipsthumbnail $tmp/t1.v -o $tmp/t2.v --size $size --interpolator $interp
|
||||
if [ $(vipsheader -f width $tmp/t2.v) -ne $size ]; then
|
||||
echo failed -- bad size
|
||||
exit
|
||||
fi
|
||||
if [ $(vipsheader -f height $tmp/t2.v) -ne $size ]; then
|
||||
echo failed -- bad size
|
||||
exit
|
||||
fi
|
||||
vips project $tmp/t2.v $tmp/cols.v $tmp/rows.v
|
||||
|
||||
min=$(vips min $tmp/cols.v)
|
||||
if break_threshold $min 0; then
|
||||
echo failed -- has a black column
|
||||
exit
|
||||
fi
|
||||
|
||||
min=$(vips min $tmp/rows.v)
|
||||
if break_threshold $min 0; then
|
||||
echo failed -- has a black row
|
||||
exit
|
||||
fi
|
||||
|
||||
echo ok
|
||||
|
||||
size=$(($size-1))
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user