Update image.py

This commit is contained in:
H Lohaus 2024-02-10 20:16:38 +01:00 committed by GitHub
parent ebcfa97c81
commit 4ba52b3695
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -163,10 +163,10 @@ def process_image(img: Image, new_width: int, new_height: int) -> Image:
# Resize image
img.thumbnail((new_width, new_height))
# Remove transparency
if img.mode != "RGB":
if img.mode == "RGBA":
img.load()
white = new_image('RGB', img.size, (255, 255, 255))
white.paste(img, mask=img.convert('RGBA').split()[-1])
white.paste(img, mask=img.split()[-1])
return white
return img