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>
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