drewcassidy / add_photo_locations_from_gpx

Add missing location data to photos in Apple's Photos app using data from a GPX file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add location to Apple Photos from GPX File

Python script to add missing location data to photos in your Apple Photos library based on a data from a GPX file. This script can be run stand-alone to add location data to the photos in your library or via osxphotos using the osxphotos run command.

Installation

The easiest way to run this is to save the script to your computer then install osxphotos using these instructions and run the script using osxphotos run add_photo_locations_from_gpx.py.

If you're comfortable with python, you can also run this script stand-alone:

Clone the repo:

  • git clone git@github.com:RhetTbull/add_photo_locations_from_gpx.git
  • cd add_photo_locations_from_gpx

I recommend you create and activate a python virtual environment before running pip:

  • python3 -m venv venv
  • source venv/bin/activate

Then install requirements:

  • python3 -m pip requirements.txt

Requires python 3.9+

Running

python3 add_photo_locations_from_gpx.py --help

or, if running with osxphotos:

osxphotos install gpxpy
osxphotos run add_photo_locations_from_gpx.py --help

Usage: add_photo_locations_from_gpx.py [OPTIONS] GPX_FILENAME

  Add missing location data to photos in Apple Photos from GPX file.

Options:
  --delta INTEGER       Time delta in seconds, default = 60.
  --dry-run             Dry run, do not actually update location info for
                        photos.
  --add-to-album ALBUM  Add updated photos to album named ALBUM, creating the
                        album if necessary.
  --selected            Only update photos currently selected in Photos.
                        Default is to update all photos with missing location
                        data in the library.
  --help                Show this message and exit.

I strongly recommend you run with --dry-run first and manually check the locations for some of the photos. I also recommend using the --add-to-album to add all updated photos to an album so you can check the results.

--delta specifies how close in time (in seconds) the GPX timestamp needs to be (in seconds) in order to match the location to the photo's timestamp.

Photos which already have a location in Photos will not be updated even if the photo's time matches a time in the GPX file.

License

MIT License. See LICENSE file.

Dependencies

See Also

Caveat

This script can modify photos in your Photos library. Use with caution. No warranty is implied or provided.

About

Add missing location data to photos in Apple's Photos app using data from a GPX file

License:MIT License


Languages

Language:Python 100.0%