screenshot: fix bug with Pillow when comparing two images with alpha channel

This commit is contained in:
Corentin Sechet 2022-04-11 12:32:28 +02:00
parent fa8db96601
commit 52c07a934c
1 changed files with 5 additions and 2 deletions

View File

@ -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()