From 4bb517e333ba524c8a1839394223a7c2e09e1bf0 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 24 Jun 2023 19:31:32 +0000 Subject: [PATCH] accounts: Don't fail if we cannot read the avatar PIL might not support the image type. In that case, we cannot generate a thumbnail and return the source image. Fixes: #13157 Signed-off-by: Michael Tremer --- src/backend/util.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/util.py b/src/backend/util.py index 2252818e..9a4246d7 100644 --- a/src/backend/util.py +++ b/src/backend/util.py @@ -204,7 +204,12 @@ def normalize(s): def generate_thumbnail(data, size, square=False, **args): assert data, "No image data received" - image = PIL.Image.open(io.BytesIO(data)) + try: + image = PIL.Image.open(io.BytesIO(data)) + + # If we cannot open the image, we return it in raw form + except PIL.UnidentifiedImageError as e: + return data # Save image format format = image.format -- 2.47.3