From 0622a93562da6faae2be54ee12008cf13f4327bf Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sun, 1 Jun 2025 23:17:48 +0300 Subject: Stuff --- app.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app.py') diff --git a/app.py b/app.py index fe67838..bee1188 100644 --- a/app.py +++ b/app.py @@ -67,6 +67,11 @@ def download_and_create_thumbnail(file_id): response = requests.get(url) response.raise_for_status() img = Image.open(BytesIO(response.content)) + + # Convert to RGB if image has alpha channel (RGBA or P) + if img.mode in ("RGBA", "P"): + img = img.convert("RGB") + img.thumbnail((400, 400)) path = os.path.join(THUMBNAIL_DIR, f"{file_id}.jpg") img.save(path, format="JPEG") -- cgit v1.3