add: skip adding images with invalid exif to db

pull/5/head
rrr-marble 4 years ago
parent a1cd63eca0
commit b78c53441d

@ -41,16 +41,20 @@ def process_pictures(source: str, dest_shrunk: str, dest_original: str):
# Q: do we strip exif from originals?
move(path.join(root, filename), dest_original)
# return the freshly processed picture info
yield {
"ResizedImage": path.join(dest_shrunk, filename),
"OriginalImage": path.join(dest_original, filename),
"DateTimeOriginal": exif["DateTimeOriginal"], # Q: normalize it?
"GPSLatitude": exif["GPSLatitude"],
"GPSLatitudeRef": exif["GPSLatitudeRef"],
"GPSLongitude": exif["GPSLongitude"],
"GPSLongitudeRef": exif["GPSLongitudeRef"],
}
try:
# return the freshly processed picture info
yield {
"ResizedImage": path.join(dest_shrunk, filename),
"OriginalImage": path.join(dest_original, filename),
"DateTimeOriginal": exif["DateTimeOriginal"], # Q: normalize it?
"GPSLatitude": exif["GPSLatitude"],
"GPSLatitudeRef": exif["GPSLatitudeRef"],
"GPSLongitude": exif["GPSLongitude"],
"GPSLongitudeRef": exif["GPSLongitudeRef"],
}
except KeyError as e:
print(f"Image '{filename}' has no valid exif")
continue
def update_database(pic_info: dict, db_location: str):

Loading…
Cancel
Save