22
22
# The optional argument allows you to compare a subset of the images
23
23
# (only those with names starting with the specified prefix).
24
24
#
25
- # Check build/images/diff/results.txt for results. This file is sorted
26
- # by PHASH difference (most different files on top.) The composite diff
27
- # images for failed tests (i.e., PHASH > 1.0) are stored in build/images/diff.
25
+ # Check build/images/diff/results.txt for results. The composite diff
26
+ # images for failed tests are stored in build/images/diff.
28
27
#
29
28
30
29
# PNG viewer on OSX. Switch this to whatever your system uses.
@@ -36,10 +35,6 @@ LC_NUMERIC="en_US.UTF-8"
36
35
# Check ImageMagick installation
37
36
command -v convert > /dev/null 2>&1 || { echo >&2 " Error: ImageMagick not found." ; exit 1; }
38
37
39
- # Show images over this PHASH threshold. This is probably too low, but
40
- # a good first pass.
41
- THRESHOLD=0.01
42
-
43
38
# Directories. You might want to change BASE, if you're running from a
44
39
# different working directory.
45
40
BASE=.
@@ -110,7 +105,7 @@ if [ -n "$NPROC" ]; then
110
105
nproc=$NPROC
111
106
fi
112
107
113
- echo " Running $totalImagesA tests with threshold $THRESHOLD (nproc=$nproc )..."
108
+ echo " Running $totalImagesA tests (nproc=$nproc )..."
114
109
115
110
function ProgressBar {
116
111
let _progress=(${1} * 100/${2} * 100)/100
@@ -142,37 +137,24 @@ function diff_image() {
142
137
fi
143
138
144
139
# If the two files are byte-for-byte identical, skip the image comparison below.
145
- cmp -s $fileA $fileB && echo $name " 0 " > $diff .pass && return
140
+ cmp -s $fileA $fileB && return
146
141
147
142
cp $fileA $diff -a.png
148
143
cp $fileB $diff -b.png
149
144
150
- # Calculate the difference metric and store the composite diff image.
151
- local hash=` compare -metric PHASH -highlight-color ' #ff000050' $diff -b.png $diff -a.png $diff -diff.png 2>&1 `
152
-
153
- # Remove scientific notation
154
- local hash6=` printf " %.6f" $hash `
155
- local THRESHOLD6=` printf " %.6f" $THRESHOLD `
156
-
157
- local isGT=` echo " $hash6 > $THRESHOLD6 " | bc -l`
158
- if [ " $isGT " == " 1" ]
159
- then
160
- # Add the result to results.text
161
- echo $name $hash > $diff .fail
162
- # Threshold exceeded, save the diff and the original, current
163
- cp $diff -diff.png $DIFF /$name .png
164
- cp $diff -a.png $DIFF /$name ' _' $ANAME .png
165
- cp $diff -b.png $DIFF /$name ' _' $BNAME .png
166
- echo
167
- echo " Test: $name "
168
- echo " PHASH value exceeds threshold: $hash > $THRESHOLD "
169
- echo " Image diff stored in $DIFF /$name .png"
170
- # $VIEWER "$diff-diff.png" "$diff-a.png" "$diff-b.png"
171
- # echo 'Hit return to process next image...'
172
- # read
173
- else
174
- echo $name $hash > $diff .pass
175
- fi
145
+ # Store the composite diff image.
146
+ # Add the result to results.text
147
+ echo $name > $diff .fail
148
+ # Threshold exceeded, save the diff and the original, current
149
+ cp $diff -diff.png $DIFF /$name .png
150
+ cp $diff -a.png $DIFF /$name ' _' $ANAME .png
151
+ cp $diff -b.png $DIFF /$name ' _' $BNAME .png
152
+ echo
153
+ echo " Test: $name "
154
+ echo " Image diff stored in $DIFF /$name .png"
155
+ # $VIEWER "$diff-diff.png" "$diff-a.png" "$diff-b.png"
156
+ # echo 'Hit return to process next image...'
157
+ # read
176
158
rm -f $diff -a.png $diff -b.png $diff -diff.png
177
159
}
178
160
@@ -219,18 +201,15 @@ cat $BDIR/*.fail 1>$RESULTS.fail 2>/dev/null
219
201
num_fails=` cat $RESULTS .fail | wc -l`
220
202
rm -f $BDIR /* .fail
221
203
222
- # Sort results by PHASH
223
- sort -r -n -k 2 $RESULTS .fail > $RESULTS
224
- sort -r -n -k 2 $BDIR /* .pass 1>> $RESULTS 2> /dev/null
204
+ # Sort results
205
+ sort $RESULTS .fail > $RESULTS
225
206
226
207
# The previous cleanup approach (rm -f) triggered the error: Argument list too long.
227
- find $BDIR -name ' *-temp.pass' -type f -delete
228
208
rm -f $RESULTS .fail
229
209
230
210
echo
231
211
echo Results stored in $DIFF /results.txt
232
- echo All images with a difference over threshold, $THRESHOLD , are
233
- echo available in $DIFF , sorted by perceptual hash.
212
+ echo All images with a difference, are available in $DIFF .
234
213
echo
235
214
236
215
if [ " $num_warnings " -gt 0 ]
245
224
echo " You have $num_fails fail(s):"
246
225
head -n $num_fails $RESULTS
247
226
else
248
- echo " Success - All diffs under threshold !"
227
+ echo " Success - No differences !"
249
228
fi
0 commit comments