blob: 8e4bdd9741c9a1a9e5d1092edd01a2affd804515 (
plain)
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
72
73
74
|
#!/bin/bash
VERBOSE=${VERBOSE:-0}
IN=in.png
OUT=out.png
OUT_BMP=out.bmp
error() {
echo "$*" >&2
exit 1
}
verbose() {
if [ $VERBOSE != 0 ]; then
"$@"
fi
}
# under Windows we don't need to run test under Wine
WINE=wine
MAGICK=
if [ "x`uname -s`" != xLinux ]; then
WINE=
if command -V magick.exe &> /dev/null; then
MAGICK=magick.exe
fi
fi
# MSVC build put executables under <Configuration> directory
IMAGETEST=imagetest.exe
if [ -e ./Release/imagetest.exe ]; then
IMAGETEST=./Release/imagetest.exe
fi
compare_images() {
DIFF=$($MAGICK compare -metric AE $1 $2 - 2>&1 > /dev/null || true)
if [ "$DIFF" != "0" ]; then
error "Images $1 and $2 are too different, diff $DIFF"
fi
}
do_test() {
echo "Running image $IMAGE with '$*'..."
$MAGICK convert $IMAGE "$@" $IN
$WINE $IMAGETEST $IN $OUT_BMP $OUT
verbose ls -lh $IN
verbose $MAGICK identify $IN
verbose $MAGICK identify $OUT_BMP
compare_images $IN $OUT
compare_images $IN $OUT_BMP
rm -f $IN $OUT $OUT_BMP
}
do_test_all() {
IMAGE="$1"
do_test
do_test -type Palette
do_test -type Palette -colors 14
do_test -type Palette -colors 3
do_test -type TrueColor
do_test -type Grayscale -depth 8
do_test -type Grayscale -depth 2
do_test -type Grayscale -depth 4
}
set -e
# test with small image
do_test_all rose:
# test with larger image
do_test_all logo:
rm -f $IN $OUT $OUT_BMP
verbose echo Finish
|