exif error handling, release action
All checks were successful
Datadog Software Composition Analysis / Datadog SBOM Generation and Upload (push) Successful in 24s
Datadog Secrets Scanning / Datadog Static Analyzer (push) Successful in 39s
Datadog Static Analysis / Datadog Static Analyzer (push) Successful in 25s

This commit is contained in:
2025-03-14 22:31:12 -04:00
parent 1fc99dd2ce
commit fa46d82874
2 changed files with 45 additions and 5 deletions

View File

@ -101,11 +101,22 @@ class TemplateHelpers:
if orientation in [5, 6, 7, 8]:
width, height = height, width
exif = {
ExifTags.TAGS[k]: v
for k, v in img._getexif().items()
if k in ExifTags.TAGS
}
exif = {}
try:
img = Image.open(file_path)
exif_raw = img._getexif()
if exif_raw:
exif = {
ExifTags.TAGS[k]: v
for k, v in exif_raw.items()
if k in ExifTags.TAGS
}
except Exception as e:
print(f"Error processing image {file_path}: {e}")
date_taken = exif.get("DateTimeOriginal")
if not date_taken:
date_taken = format_date(file_path.stat().st_ctime)
return ImageMetadata(
width=width,
height=height,