@@ -106,9 +106,10 @@ function screenshotsMatch {
106106 local IMAGE_LATEST=" $2 "
107107
108108 # Calculate the normalized cross correllation between both images
109- NCC=$( compare -quiet -metric NCC " $IMAGE_OLD " " $IMAGE_LATEST " " $DIFF_FILE " 2>&1 )
109+ NCC=$( compare -quiet -alpha deactivate - metric NCC " $IMAGE_OLD " " $IMAGE_LATEST " " $DIFF_FILE " 2>&1 )
110110
111- if [ " $NCC " -lt " $NCC_THRESHOLD " ]; then
111+ # Compare floats
112+ if [ $( echo " ${NCC} <${NCC_THRESHOLD} " | bc -l) -eq 1 ]; then
112113 # The screenshots are not identical
113114 echo " Possible change detected. Confirming..."
114115
@@ -131,25 +132,25 @@ function screenshotsMatch {
131132
132133 # Compare the two cropped screenshots again
133134 # Calculate the normalized cross correllation between both images
134- NCC=$( compare -quiet -metric NCC " $IMAGE_OLD " " $IMAGE_LATEST " " $DIFF_FILE " 2>&1 )
135+ NCC=$( compare -quiet -alpha deactivate - metric NCC " $IMAGE_OLD " " $IMAGE_LATEST " " $DIFF_FILE " 2>&1 )
135136
136- if [ " $ NCC" -lt " $NCC_THRESHOLD " ]; then
137+ if [ $( echo " ${ NCC} < ${NCC_THRESHOLD} " | bc -l ) -eq 1 ]; then
137138 # The screenshots do not match. The website has changed
138139
139140 # Write detailed NCC information to a file (and don't overwrite the diff file)
140- compare -verbose -metric NCC " $IMAGE_OLD " " $IMAGE_LATEST " /dev/null & > " $NCC_FILE "
141+ compare -verbose -alpha deactivate - metric NCC " $IMAGE_OLD " " $IMAGE_LATEST " /dev/null & > " $NCC_FILE "
141142
142143 # Return false, as the screenshots do not match
143- # In bash: 1 == false
144+ # In bash: return value 1 == error == false
144145 return 1
145146 fi
146147 fi
147148
148149 # Write detailed NCC information to a file (and don't overwrite the diff file)
149- compare -verbose -metric NCC " $IMAGE_OLD " " $IMAGE_LATEST " /dev/null & > " $NCC_FILE "
150+ compare -verbose -alpha deactivate - metric NCC " $IMAGE_OLD " " $IMAGE_LATEST " /dev/null & > " $NCC_FILE "
150151
151152 # If statement above didn't exit, that means we have no mismatching hashes and therefore the screenshots match (return true)
152- # In bash: 0 == true
153+ # In bash: return value 0 == true
153154 return 0
154155}
155156
0 commit comments