rmm commited on
Commit
8cb071c
·
1 Parent(s): 02c8028

fix: replaced loop over dict with direct key lookup for datetime info

Browse files
Files changed (1) hide show
  1. src/input_handling.py +2 -3
src/input_handling.py CHANGED
@@ -186,9 +186,8 @@ def get_image_datetime(image_file: UploadedFile) -> str | None:
186
  image = Image.open(image_file)
187
  exif_data = image._getexif()
188
  if exif_data is not None:
189
- for tag, value in exif_data.items():
190
- if ExifTags.TAGS.get(tag) == 'DateTimeOriginal':
191
- return value
192
  except Exception as e: # FIXME: what types of exception?
193
  st.warning(f"Could not extract date from image metadata. (file: {image_file.name})")
194
  # TODO: add to logger
 
186
  image = Image.open(image_file)
187
  exif_data = image._getexif()
188
  if exif_data is not None:
189
+ if ExifTags.Base.DateTimeOriginal in exif_data:
190
+ return exif_data.get(ExifTags.Base.DateTimeOriginal)
 
191
  except Exception as e: # FIXME: what types of exception?
192
  st.warning(f"Could not extract date from image metadata. (file: {image_file.name})")
193
  # TODO: add to logger