bugfix : try to use different exif tag for datetime

This commit is contained in:
Antoine Van Elstraete 2019-05-17 19:01:46 +02:00 committed by Antoine Van Elstraete
parent e40f546137
commit bb90e192e9

22
exv.py
View File

@ -48,7 +48,9 @@ def extractor(input_files, start, end, recursive):
"Photo.PixelYDimension",
"Image.ImageWidth",
"Image.ImageLength",
"Photo.DateTimeOriginal"
"Photo.DateTimeOriginal",
"Photo.DateTimeDigitized",
"Exif.Image.DateTime"
]
for item in input_files:
if isdir(item):
@ -72,9 +74,9 @@ def extractor(input_files, start, end, recursive):
extracted_data = extracted_data.stdout.read().decode()
if extracted_data:
extracted_data = extracted_data.splitlines()[0]
exif_dict.update({extracted.split(".")[1]: extracted_data})
exif_dict.update({extracted.split(".")[-1]: extracted_data})
else:
exif_dict.update({extracted.split(".")[1]: None})
exif_dict.update({extracted.split(".")[-1]: None})
if exif_dict['FocalLength']:
exif_dict['FocalLength'] = float(
exif_dict['FocalLength'].replace(" mm", ""))
@ -94,8 +96,16 @@ def extractor(input_files, start, end, recursive):
else:
pixels = None
if exif_dict['DateTimeOriginal']:
exif_dict['DateTimeOriginal'] = datetime.strptime(
exif_dict['DateTime'] = datetime.strptime(
exif_dict['DateTimeOriginal'], "%Y:%m:%d %H:%M:%S")
elif exif_dict['DateTimeDigitized']:
exif_dict['DateTime'] = datetime.strptime(
exif_dict['DateTimeDigitized'], "%Y:%m:%d %H:%M:%S")
elif exif_dict['DateTime']:
exif_dict['DateTime'] = datetime.strptime(
exif_dict['DateTime'], "%Y:%m:%d %H:%M:%S")
else:
exif_dict['DateTime'] = None
if exif_dict['ExposureTime']:
try:
exif_dict['ExposureTime'] = float(
@ -114,7 +124,7 @@ def extractor(input_files, start, end, recursive):
cameras_list, lenses_list, focals_list, apertures_list, exposures_list = [], [], [], [], []
isos_list, dimensions_list, cameras_lenses_list, dates_list = [], [], [], []
for data in exif_dict_list:
if start <= data['DateTimeOriginal'] <= end:
if data['DateTime'] and start <= data['DateTime'] <= end:
cameras_list.append(data['Model'])
lenses_list.append(data['LensModel'])
focals_list.append(data['FocalLength'])
@ -125,7 +135,7 @@ def extractor(input_files, start, end, recursive):
if data['LensModel']:
cameras_lenses_list.append(
"{} + {}".format(data['Model'], data['LensModel']))
dates_list.append(data['DateTimeOriginal'].strftime("%Y%m%d"))
dates_list.append(data['DateTime'].strftime("%Y%m%d"))
for camera in list(set(cameras_list)):
if camera:
cameras.update({camera: cameras_list.count(camera)})