/ PHOTOGRAPHY

Geotagging Photos with ExifTool

A pile of great photos at hand? But the locations only in your head? Here’s how to geotag those photos using Bash and ExifTool.

When All You Have is a Distant Memory

Ever since I discovered geotagging, I’ve never gone back — I make sure to geotag all my photos! This way, the information of where I took each photo is contained inside the photo itself.

Most of the time, I rely on my GPS tracker to provide me with a GPS track and then let Bash and ExifTool do all the heavy lifting as described in Why I Geotag My Photos.

Man Looking at Laptop

But once in a while, I am faced with a problem I thought to belong to the dark ages.

Great photos at hand. But the location information only in my head (and rapidly fading). Because I forgot to bring my GPS Tracker, the photos predate the purchase of the GPS tracker, or any other excuse I could come up with.

So, how to make sure those great photos are properly geotagged?

All You Really Need is Bash… and ExifTool

The good news is that it’s fairly easy to geotag a pile of photos without a GPS Track at hand. It’s just a bit more cumbersome.

ExifTool Help in Bash

All you really need for the job is Bash and ExifTool. What they are, why it makes sense to only use those tools, and how to install them on a recent Mac is described in article Why I Geotag My Photos.

The rest of this article assumes that you have ExifTool installed and are familiar with Bash to some degree.

Geotagging Selected Photos

Suppose you know that the below photo, called university_of_greenwich.jpg, was actually taken at the University of Greenwich — just as it says on the tin.

You’ve also located the position of the photo to be 51.483822 N, 0.006572 W with the help of Google Maps by clicking the corresponding location on the map and taking the location information from the small overlay towards the bottom of the window.

University of Greenwich

Adding a GPS Location

The corresponding location information can then be embedded into university_of_greenwich.jpg with exiftool via the following command

exiftool -GPSLongitudeRef=W -GPSLongitude=0.006572 -GPSLatitudeRef=N -GPSLatitude=51.483822 university_of_greenwich.jpg

In case you only have the location information in degrees minutes seconds (DMS) such as 51 deg 29' 1.76" N, 0 deg 0' 23.66" W, then a free online conversion tool comes in handy to convert it to decimal degree (DD) 51.483822 N, 0.006572 W.

At this point, the location information in university_of_greenwich.jpg is

$ exiftool university_of_greenwich.jpg | grep GPS
GPS Version ID                  : 2.3.0.0
GPS Latitude Ref                : North
GPS Longitude Ref               : West
GPS Latitude                    : 51 deg 29' 1.76" N
GPS Longitude                   : 0 deg 0' 23.66" W
GPS Position                    : 51 deg 29' 1.76" N, 0 deg 0' 23.66" W

Adding a GPS Date Stamp

The above step adds the GPS location information to the photo but leaves the GPS Date Stamp untouched. It’s only a nuance. But it shows in Preview on a Mac. And it’s easy to fix given the date stamp of when the photo was take is available.

The following command copies the modified date of the photo into the GPS Date Stamp

exiftool university_of_greenwich.jpg "-GPSDateStamp<ModifyDate" -globalTimeShift

At this point, the location information in university_of_greenwich.jpg is

$ exiftool university_of_greenwich.jpg | grep GPS
GPS Version ID                  : 2.3.0.0
GPS Latitude Ref                : North
GPS Longitude Ref               : West
GPS Date Stamp                  : 2016:11:13
GPS Latitude                    : 51 deg 29' 1.76" N
GPS Longitude                   : 0 deg 0' 23.66" W
GPS Position                    : 51 deg 29' 1.76" N, 0 deg 0' 23.66" W

Shifting all EXIF Dates

In case all EXIF dates (except for the GPS Date Stamp) are behind by one year, they can all be adjusted via

exiftool "-AllDates+=1:00:00 00:00:00" university_of_greenwich.jpg

Here, the general input format for AllDates is [Y]{1,4}:mm:dd HH:MM:SS with additional nuances and specialties available. Fill your boots!

Note that in order to also shift the GPS Date Stamp, simply repeat the above step of copying the modified date of the photo into the GPS Date Stamp.

Copying EXIF Information Between Photos

If the above steps are too much hassle then you can also copy all EXIF tags from source.jpg to target.jpg via

exiftool -TagsFromFile source.jpg target.jpg

Note that this operation merely copies the metadata. It does not adjust it. This means that metadata such as aperture, resolution, and size do not get updated in the process. Hence, this is most useful when working with identical photos.

Deleting all GPS Tags

All GPS tags in university_of_greenwich.jpg can be deleted via

exiftool -GPS*= university_of_greenwich.jpg

Deleting all Tags

All EXIF tags in university_of_greenwich.jpg can be deleted via

exiftool -all= university_of_greenwich.jpg

The command is also one of the pillars of my Bash script that I use to prepare all images for publication. This way, I Leave No Trace and don’t litter the internet with additional and potentially harmful EXIF tags.

Useful ExifTool Flags

ExifTool plays it safe by default and keeps a copy of each original file around. This is why after updating university_of_greenwich.jpg, a new file called university_of_greenwich.jpg_original suddenly appears. This can be suppressed by enabling in place updates via flag

-overwrite_original

When working with larger batches, exiftool can be incentivised to show progress via flag

-progress

Moreover, the verbosity of exiftool can be increased via flag

-verbose

The full documentation of ExifTool can be found on the corresponding exiftool Application Documentation. Or right inside your Bash shell via man exiftool. All you really need is Bash!

Conclusion

Bash and ExifTool get the job done for me when it comes to a pile of photos for which I want to get the locations out of my head and inside the photos. Text book geotagging.

Think this is all rubbish and I should much rather use the-one-special-tool-that-really-does-it-all-and-is-also-clearly-better-than-everything-else?! Feel free to reach out to me on LinkedIn and teach me something new!

As always, prove me wrong and I’ll buy you a pint!

dominic

Dominic Dumrauf

A Cloud Success Champion by profession, an avid outdoor enthusiast by heart, and a passionate barista by choice. Still hunting that elusive perfect espresso.

Read More