Skip to content

Commit

Permalink
Ensure images are converted to RGB for diff checking + add image size…
Browse files Browse the repository at this point in the history
… check

Summary: For some odd reason `ImageChops.difference` does not work at all with RGBA formatted images, so this forces images to be in RGB format prior to diffing (which may also indicate that we're dropping alpha only changes). This also adds a change to check for image dimension differences to partially address the concerns in #292

Differential Revision: D33961675

fbshipit-source-id: 893cb07568893e74a9717b6c90fc9b1ab065feb3
  • Loading branch information
xiphirx authored and facebook-github-bot committed Feb 3, 2022
1 parent 4651d84 commit 52c2ce1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugin/src/py/android_screenshot_tests/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ def _clean(self):

def _is_image_same(self, file1, file2, failure_file):
with Image.open(file1) as im1, Image.open(file2) as im2:
diff_image = ImageChops.difference(im1, im2)
diff_image = ImageChops.difference(im1.convert("RGB"), im2.convert("RGB"))
try:
diff = diff_image.getbbox()
if diff is None:
if diff is None and im1.size == im2.size:
return True
else:
if failure_file:
Expand Down

0 comments on commit 52c2ce1

Please sign in to comment.