import glob
= 'sample-data/*.jpg'
path = glob.glob(path)
images len(images)
2
Use exif explorer to build up a list of image metadata
image_list[0].exif.get("datetime_original")
# note that some of these can be None, since some images are created by google photos
'2018:11:30 07:57:21'
Now we need to convert the to a timestamp the dates from exif
to_timestamp (date)
# testing to make sure we get the right value back
timestamp = to_timestamp(image_list[0].exif.get("datetime_original"))
timestamp
1543579041
get_time_delta (a, b)
delta_to_minutes (delta)
Now lets pull some information from location history to compare
Location(timestamp=1467216494, latitude=446549411, longitude=-635836042, accuracy=41)
Now lets come up with a bruteforce solution to finding the aligning dates from both datasets
get_smallest_deltas (image_list, locations)
Now we can take a peek at how close the date ranges between the image timestamps and location history timestamps are.
de_google_gps_info (d, image_list, locations)
convert_to_decimal (lat, long)
ImageGPS(image_path='sample-data/sample.jpg', gps=(44.6551683, -63.5835479))
From here we can start associating the GPS data from the location history to the images that Google Photo’s has stripped.
write_gps_info_to_images (image_list, output_path)
exif:GPSAltitude=94940/11161
exif:GPSAltitudeRef=.
exif:GPSDestBearing=227653/2182
exif:GPSDestBearingRef=T
exif:GPSHPositioningError=33479/4096
exif:GPSImgDirection=227653/2182
exif:GPSImgDirectionRef=T
exif:GPSInfo=2272
exif:GPSLatitude=45/1, 30/1, 5110/100
exif:GPSLatitudeRef=N
exif:GPSLongitude=73/1, 31/1, 3981/100
exif:GPSLongitudeRef=W
exif:GPSSpeed=4744/18627
exif:GPSSpeedRef=K