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
This commit is contained in:
skybldev 2021-11-29 21:23:47 -05:00
parent 066993ee07
commit a48c792322

View file

@ -1,13 +1,20 @@
import json import json
import logging
from datetime import datetime from datetime import datetime
from subprocess import PIPE, Popen from subprocess import PIPE, Popen
from typing import Optional from typing import Optional
from exif import Image from exif import Image
logger = logging.getLogger(__name__)
def resolve_image_date_taken(content: bytes) -> Optional[datetime]: 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 img.has_exif:
if "datetime" in img.list_all(): if "datetime" in img.list_all():