0

Using exiftool, if I have a file named foobar.jpeg and the shell variables lat="37.7708" and lon="-122.451".

What command do I use to set the EXIF metadata for that jpeg file such that its "geotag" / GPS metadata is set with those coordinates.

Chris W.
  • 37,583
  • 36
  • 99
  • 136

1 Answers1

1

exiftool "-GPSLatitude=$lat" "-GPSLatitudeRef=$lat" "-GPSLongitude=$lon" "-GPSLongitudeRef=$lon" foobar.jpeg

Because the GPS coordinates tags are unsigned, you need to make sure and assign the values to the relevant GPSLatitudeRef/GPSLongitudeRef tags as well, especially if the location is in the Western and/or Southern hemisphere. Even though these values would normally be set with N/S and E/W, exiftool well accept the raw values and figure out the proper Ref direction from that.

StarGeek
  • 4,948
  • 2
  • 19
  • 30
  • I finally figured this out on my own, but didn’t realize about the ‘ref’ aspect. Thanks so much! – Chris W. May 15 '18 at 16:46