Skip to content

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

License

Notifications You must be signed in to change notification settings

RhetTbull/add_photo_locations_from_gpx

Repository files navigation

Add location to Apple Photos from GPX File

All Contributors

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 install osxphotos using these instructions and run the script using:

  osxphotos run https://raw.githubusercontent.com/RhetTbull/add_photo_locations_from_gpx/refs/heads/main/add_photo_locations_from_gpx.py FILENAME.gpx

To see the help for the script, run:

  osxphotos run https://raw.githubusercontent.com/RhetTbull/add_photo_locations_from_gpx/refs/heads/main/add_photo_locations_from_gpx.py --help

You can also save the script locally and run it:

  osxphotos run add_photo_locations_from_gpx.py FILENAME.gpx

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 -r 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.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Kevin Yank
Kevin Yank

📖
Torben
Torben

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages