Skip to content

Commit e1010af

Browse files
Johannes Sixtj6t
authored andcommitted
imgdiff: Compare images of different size.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
1 parent 30bcf91 commit e1010af

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

contrib/imgdiff/imgdiff

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/sh
22

33
d=$TMP/imgdiff$$.png
4+
a=$TMP/imgdiff$$a.miff
5+
b=$TMP/imgdiff$$b.miff
46

5-
trap 'rm -f "$d"' 0 1 2 15
7+
trap 'rm -f "$d" "$a" "$b"' 0 1 2 15
68

79
if test $# = 7; then
810
of="$2"
@@ -32,5 +34,20 @@ else
3234
echo "Images $of and $nf differ"
3335
fi
3436

35-
compare -virtual-pixel black "$of" "$nf" "$d" &&
37+
# compute image sizes
38+
sa=$(identify "$of")
39+
sb=$(identify "$nf")
40+
sa=${sa#"$of "* }
41+
sb=${sb#"$nf "* }
42+
sa=${sa%% *}
43+
sb=${sb%% *}
44+
45+
if test "$sa" != "$sb"; then
46+
# sizes differ; must construct images of the same size
47+
convert "xc:none[$sa!]" -scale "$sb<" "$of" -composite "$a" &&
48+
convert "xc:none[$sa!]" -scale "$sb<" "$nf" -composite "$b"
49+
of=$a
50+
nf=$b
51+
fi &&
52+
compare "$of" "$nf" "$d" &&
3653
imdisplay "$d"

0 commit comments

Comments
 (0)