Skip to content

Commit 16aa488

Browse files
authored
fix: fix bug in fast path (#18)
fix: fix bug in fast path
1 parent 664bb98 commit 16aa488

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

fixtures/7a.png

Lines changed: 3 additions & 0 deletions
Loading

fixtures/7b.png

Lines changed: 3 additions & 0 deletions
Loading

fixtures/7diff.png

Lines changed: 3 additions & 0 deletions
Loading

pixelmatch.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,10 @@ def pixelmatch(img1, img2, width: int, height: int, output=None, options=None):
2525
else:
2626
options = DEFAULT_OPTIONS
2727

28-
# check if images are identical
29-
image_len = width * height
30-
identical = True
31-
32-
for i in range(image_len):
33-
if img1[i] != img2[i]:
34-
identical = False
35-
break
36-
3728
# fast path if identical
38-
if identical:
29+
if img1 == img2:
3930
if output and not options["diff_mask"]:
40-
for i in range(image_len):
31+
for i in range(width * height):
4132
draw_gray_pixel(img1, 4 * i, options["alpha"], output)
4233

4334
return 0

test_pixelmatch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def pil_to_flatten_data(img):
4747
["5a", "5b", "5diff", OPTIONS, 0],
4848
["6a", "6b", "6diff", OPTIONS, 51],
4949
["6a", "6a", "6empty", {"threshold": 0}, 0],
50+
["7a", "7b", "7diff", OPTIONS, 9856],
5051
]
5152

5253

0 commit comments

Comments
 (0)