]> git.ipfire.org Git - ipfire.org.git/commitdiff
accounts: Don't fail if we cannot read the avatar
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 24 Jun 2023 19:31:32 +0000 (19:31 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 24 Jun 2023 19:31:32 +0000 (19:31 +0000)
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 <michael.tremer@ipfire.org>
src/backend/util.py

index 2252818ea538455812d324c4787700224178f892..9a4246d70dca7fbce6c4d7d0722c6af1a82b4d32 100644 (file)
@@ -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