handle exceptions when extracting EXIF and XMP data from images

This commit is contained in:
2026-04-02 12:47:54 +02:00
committed by Florian Greistorfer
parent 4789dd6232
commit ebce2aa21d

View File

@@ -168,8 +168,14 @@ def get_image_info(item: str, folder: str) -> ImageMetadata:
with Image.open(file) as img: with Image.open(file) as img:
logger.info("extracting image information", extra={"file": file}) logger.info("extracting image information", extra={"file": file})
width, height = img.size width, height = img.size
exif = img.getexif() try:
xmpdata = img.getxmp() exif = img.getexif()
except Exception:
exif = None
try:
xmpdata = img.getxmp()
except Exception:
xmpdata = None
except UnidentifiedImageError: except UnidentifiedImageError:
logger.error("cannot identify image file", extra={"file": file}) logger.error("cannot identify image file", extra={"file": file})