From a48c792322dcc0a8f49b7dca16441c232811bc3b Mon Sep 17 00:00:00 2001 From: skybldev Date: Mon, 29 Nov 2021 21:23:47 -0500 Subject: [PATCH] server: catch failure to read image exif - [server] wrapped exif image reading in a try..except, since it can fail for some images. Also added a logger message to make it easier to debug in the future, to fix compatibility issues and make debugging easier --- server/szurubooru/func/metadata.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/szurubooru/func/metadata.py b/server/szurubooru/func/metadata.py index 16d87ca8..cf7ed232 100644 --- a/server/szurubooru/func/metadata.py +++ b/server/szurubooru/func/metadata.py @@ -1,13 +1,20 @@ import json +import logging from datetime import datetime from subprocess import PIPE, Popen from typing import Optional from exif import Image +logger = logging.getLogger(__name__) + def resolve_image_date_taken(content: bytes) -> Optional[datetime]: - img = Image(content) + try: + img = Image(content) + except Exception: + logger.warning("Error reading image with exif library!") + return None if img.has_exif: if "datetime" in img.list_all():