File: variables.sh.in

package info (click to toggle)
vips 8.17.3-2
  • links: PTS
  • area: main
  • in suites: forky, 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 (64 lines) | stat: -rw-r--r-- 1,489 bytes parent folder | download | duplicates (2)
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
top_srcdir=@abs_top_srcdir@
top_builddir=@abs_top_builddir@
PYTHON=@PYTHON@
# we need a different tmp for each script since make can run tests in parallel
tmp=$top_builddir/test/tmp-$$
test_images=$top_srcdir/test/test-suite/images
image=$test_images/sample.jpg
mkdir -p $tmp
vips=$top_builddir/tools/vips
vipsthumbnail=$top_builddir/tools/vipsthumbnail
vipsheader=$top_builddir/tools/vipsheader

# we need bc to use '.' for a decimal separator
export LC_NUMERIC=C

# raspbian sets this too, annoyingly
unset LC_ALL

# test for file format supported
test_supported() {
	format=$1

	if $vips $format > /dev/null 2>&1; then
		result=0
	else
		echo "support for $format not configured, skipping test"
		result=1
	fi

	return $result
}

# 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
	if ! command -v bc >/dev/null; then
		exit 77
	fi
	return $(echo "$diff <= $threshold" | bc -l)
}

# subtract, look for max difference less than a threshold
test_difference() {
	before=$1
	after=$2
	threshold=$3

  # compare in srgb space
	$vips colourspace $before $tmp/b-rgb.v srgb
	$vips colourspace $after $tmp/a-rgb.v srgb

	$vips subtract $tmp/b-rgb.v $tmp/a-rgb.v $tmp/difference.v
	$vips abs $tmp/difference.v $tmp/abs.v
	dif=$($vips max $tmp/abs.v)

	if break_threshold $dif $threshold; then
		echo "save / load difference is $dif"
		exit 1
	fi
}