diff --git a/fixtures/7a.png b/fixtures/7a.png new file mode 100644 index 0000000..a3cffe4 Binary files /dev/null and b/fixtures/7a.png differ diff --git a/fixtures/7b.png b/fixtures/7b.png new file mode 100644 index 0000000..d4ccb9b Binary files /dev/null and b/fixtures/7b.png differ diff --git a/fixtures/7diff.png b/fixtures/7diff.png new file mode 100644 index 0000000..d99c51b Binary files /dev/null and b/fixtures/7diff.png differ diff --git a/pixelmatch.py b/pixelmatch.py index d27c304..dacc8d7 100644 --- a/pixelmatch.py +++ b/pixelmatch.py @@ -25,19 +25,10 @@ def pixelmatch(img1, img2, width: int, height: int, output=None, options=None): else: options = DEFAULT_OPTIONS - # check if images are identical - image_len = width * height - identical = True - - for i in range(image_len): - if img1[i] != img2[i]: - identical = False - break - # fast path if identical - if identical: + if img1 == img2: if output and not options["diff_mask"]: - for i in range(image_len): + for i in range(width * height): draw_gray_pixel(img1, 4 * i, options["alpha"], output) return 0 diff --git a/test_pixelmatch.py b/test_pixelmatch.py index 07e6627..a225959 100644 --- a/test_pixelmatch.py +++ b/test_pixelmatch.py @@ -47,6 +47,7 @@ def pil_to_flatten_data(img): ["5a", "5b", "5diff", OPTIONS, 0], ["6a", "6b", "6diff", OPTIONS, 51], ["6a", "6a", "6empty", {"threshold": 0}, 0], + ["7a", "7b", "7diff", OPTIONS, 9856], ]