You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi sorry! not sure what the etiquette is for contributing but when i ran the script and downloaded the images, i noticed that the time metadata was set to UTC by default. i made some changes that set it to the right timezone according to the location where the picture was taken and could contribute my code if you'd like
i added this to the update_exif function to fix it
if location and 'latitude' in location and 'longitude' in location:
logging.info(f"Found location: {location}")
gps_ifd = {
piexif.GPSIFD.GPSLatitudeRef: 'N' if location['latitude'] >= 0 else 'S',
piexif.GPSIFD.GPSLatitude: _convert_to_degrees(abs(location['latitude'])),
piexif.GPSIFD.GPSLongitudeRef: 'E' if location['longitude'] >= 0 else 'W',
piexif.GPSIFD.GPSLongitude: _convert_to_degrees(abs(location['longitude'])),
}
exif_dict['GPS'] = gps_ifd
logging.info(f"Added GPS location: {gps_ifd}")
longitude = location['longitude']
offset_hours = longitude / 15.0 # 1 hour per 15 degrees
offset_timedelta = timedelta(hours=round(offset_hours))
datetime_local = datetime_original + offset_timedelta
datetime_str = datetime_local.strftime("%Y:%m:%d %H:%M:%S")
exif_dict['Exif'][piexif.ExifIFD.DateTimeOriginal] = datetime_str
logging.info(f"Adjusted capture time to local timezone: {datetime_str}")
else:
datetime_str = datetime_original.strftime("%Y:%m:%d %H:%M:%S")
exif_dict['Exif'][piexif.ExifIFD.DateTimeOriginal] = datetime_str
logging.error(f"Could not determine timezone. Set capture time to UTC: {datetime_str}")`
The text was updated successfully, but these errors were encountered:
Hey @maithyy, thanks for raising this issue and your contribution, adding the correct timezone is something I completely overlooked. There's not really an etiquette for contributing to this repo, but generally speaking you can always go ahead and open a pull request that I'll check and merge if everything looks good and works for me as well.
Looking at your code, I noticed that you're calculating timezones by an offset depending on the longitude, which is a perfectly fine approximation but may not always be completely accurate as timezones are also influenced by political boundaries. I'm therefore not completely sure how to proceed and can think of two ways:
use libraries timezonefinder and pytz to match gps locations to their corresponding time zone
ask user, when running the script, if they want to enter a timezone offset and then apply this offset to all photos.
I'm currently leaning towards option one, as it's more flexible when photos have been taken in different locations but I won't have time to come around and implement this for some time. So if it's something, you'd be up to, feel free to fork this repository, implement the timezone matching and create a pull request! :)
If you use location to determine a user's timezone, be aware that users with "Precise Location" off (see https://support.apple.com/en-us/102647) might see incorrect timezones. Users who don't share location at all should still be able to manually enter their correct timezone.
I just realized all my photos had incorrect GPS data due to not sharing my specific location with the app, so I had to remove the location data. I used a tool called A Better Finder Attributes 7 (see https://www.publicspace.net/ABetterFinderAttributes/index.html) to adjust timestamps based on filenames and include timezone offsets.
hi sorry! not sure what the etiquette is for contributing but when i ran the script and downloaded the images, i noticed that the time metadata was set to UTC by default. i made some changes that set it to the right timezone according to the location where the picture was taken and could contribute my code if you'd like
i added this to the update_exif function to fix it
The text was updated successfully, but these errors were encountered: