From 52c07a934c8f8ece0c13a5de61e1615da12bf92b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20S=C3=A9chet?= Date: Mon, 11 Apr 2022 12:32:28 +0200 Subject: [PATCH] screenshot: fix bug with Pillow when comparing two images with alpha channel --- frontools/screenshot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontools/screenshot.py b/frontools/screenshot.py index 439fb9a..161fd3e 100644 --- a/frontools/screenshot.py +++ b/frontools/screenshot.py @@ -67,14 +67,17 @@ async def _diff_url(left: Browser, right: Browser, url: str, output_path: Path) with NamedTemporaryFile(mode="wb") as left_file: left_file.write(left_bytes) - left_image = Image.open(left_file.name) + left_image = Image.open(left_file.name).convert('RGB') with NamedTemporaryFile(mode="wb") as right_file: right_file.write(right_bytes) - right_image = Image.open(right_file.name) + right_image = Image.open(right_file.name).convert('RGB') diff = ImageChops.difference(left_image, right_image) + if not diff.getbbox(): + return + url_slug = get_url_slug(url) if not output_path.is_dir(): output_path.mkdir()