aboutsummaryrefslogtreecommitdiffstats
path: root/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'app.py')
-rw-r--r--app.py5
1 files changed, 5 insertions, 0 deletions
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")