diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-06-01 23:17:48 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-06-01 23:17:48 +0300 |
| commit | 0622a93562da6faae2be54ee12008cf13f4327bf (patch) | |
| tree | 177952ecc1672411de134124375a519692ae0927 /app.py | |
| parent | 1144b33e33bbf3a05e4e75df8a677c8aa82a3137 (diff) | |
Stuff
Diffstat (limited to 'app.py')
| -rw-r--r-- | app.py | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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") |
