Skip to content

Instantly share code, notes, and snippets.

@jareware
Last active June 28, 2018 18:31
Show Gist options
  • Save jareware/9b93d6c24fae15c40e7e to your computer and use it in GitHub Desktop.
Save jareware/9b93d6c24fae15c40e7e to your computer and use it in GitHub Desktop.
Media Geotagging and Massaging on macOS

Media Geotagging and Massaging on macOS

Synchronizing image timestamps

The one and only ExifTool will adjust the various timestamps in Exif data. Take a look at the current values:

$ exiftool DSC02833.JPG | grep Date

If this camera is behind the reference camera (that you want to sync with) by, say, 6 hours, 58 minutes and 10 seconds, add that much to each image in the dir:

$ exiftool "-AllDates+=0:0:0 6:58:10" .

Finally, to go the extra mile, overwrite the filesystem modification times to match:

$ exiftool "-DateTimeOriginal>FileModifyDate" .

Note that you may want to run this only after completing some of the below steps, as they may also touch the filesystem metadata.

Massaging GPS tracks

RouteConverter is really handy at merging/splitting one or multiple tracks per GPX file. For some reason it wouldn't run directly, but had to be started with:

$ cd RouteConverterMac64.app/Contents/MacOS
$ open JavaApplicationStub

Geotagging images

Note: A previous iteration of this guide used GpsPrune for this step. See the revision history if interested.

The following assumptions should hold:

  • Correct Exif timestamps have been set on the images (see above)
  • The timestamps are in local time for where the photos were taken (which is what you usually want, as sadly Exif timestamps don't contain timezone information)

We'll use the geotagging facility built directly into exiftool. But first, note the difference between the timezone of your machine, and the location at which your photos were taken. For instance, if you're currently in Helsinki in the summer (UTC+3), and you took the photos in the Azores (UTC+0), the difference would be +3 hours. This will geotag the photos:

$ exiftool -geotag "path/to/*.gpx" -geosync="+3:0:0" .

To quickly check what's been written for each file on the command line:

$ for f in `ls -1 *.JPG`; do echo "$f @ $(exiftool -s3 -GPSPosition $f)"; done

Batch-renaming images

Using the various features of exiftool, batch renames are easy:

$ exiftool '-filename<${CreateDate}_Name.%le' -globalTimeShift '+0:0:0 0:0:0' -d '%Y-%m-%d_%H-%M-%S%%+c' .

This will create standard filenames such as:

2017-02-24_23-15-25_Name.jpg

The _Name part is optional, and can be omitted if you don't want any extra labels on the filenames. If two images have the exact same timestamp, they'll be differentiated as e.g.:

2017-02-24_23-15-25_Name.jpg
2017-02-24_23-15-25_1_Name.jpg
2017-02-24_23-15-25_2_Name.jpg
...

Combining GPS tracks

Using GPSBabel you can:

$ cd path/with/some/gpx/files/
$ ff=""; for f in *.gpx; do ff="$ff -f $f"; done
$ gpsbabel -i gpx $ff -o gpx -F all.gpx

If the resulting file is too large, you can always simplify it a bit:

$ gpsbabel -i gpx -f all.gpx -x simplify,count=100 -o gpx -F simplified.gpx

Play with the number 100 to see how much detail you want to preserve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment