File: test_thumbnail.sh

package info (click to toggle)
vips 8.17.3-2
  • links: PTS
  • area: main
  • in suites: sid
  • size: 52,228 kB
  • sloc: ansic: 169,684; cpp: 12,156; python: 4,887; sh: 733; perl: 40; makefile: 25; javascript: 6
file content (71 lines) | stat: -rwxr-xr-x 1,697 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh

# resize a 1000x1000 image to every size in [100,1000], check for black 

# see https://github.com/libvips/libvips/issues/131

# set -x

. ./variables.sh

# 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
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

# 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)
}

# 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
		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
		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
		echo $tmp/t1.v failed -- has a black column
		exit
	fi

	min=$($vips min $tmp/rows.v)
	if break_threshold $min 0; then
		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
		exit
	fi

	echo ok

	size=$(($size-1))       
done