Skip to content

Latest commit

 

History

History
60 lines (33 loc) · 3.41 KB

geotagraw.md

File metadata and controls

60 lines (33 loc) · 3.41 KB

geotagraw.pl

Synopsis

A Perl script to copy geotags from JPGs to the corresponding raw file.

Usage

% geotagraw will process files in the current and all subdirectories.

% geotagraw --nosubdirs will only process files in the current directory.

Options

  • -n, --nosubdirs: do not process any subdirectories.

  • -r, --readonly: simulate copying the tags but do not update the raw file.

  • -d, --debug: print extra information (in practice, it only prints out the results of a calls to Data::Dumper at the moment).

  • -f <file>, --files=<file>: process list of files generated by a previous read-only pass.

  • -q,--quiet: suppress most text output.

Description

The script looks for files with known raw format extensions and then in turn checks for correspondingly named JPGs. The Image::ExifTool module is used to read and copy all tags in the gps namespace from the JPG to the corresponding raw file.

geotagraw will look for an equivalently named JPG first: e.g., for a file called DSC05124.ARW it will look for DSC05124.JPG first. Failing that, it will pick the first JPG that matches the filename. For example, I use DxO Optics Pro and processed JPGs have _DxO9 appended to the filename. The script will look for those JPGs too and will check the first one it finds for geotags. (Of course, if that file does not contain any geotags but others do, then the program will never know about them.)

The JPG geotags are taken as truth: if geotagraw finds existing geotags in the raw file, they will be compared with those in the JPG and if different, will be replaced.

By default, the script processes all subdirectories recursively, so be careful with the contents of those directories if you don't want the geotags transferred. Use the -n or --nosubdirs option to prevent this behaviour.

Specifying the read-only option will generate a text file in the current directory that contains names of the raw files along with their corresponding JPGs and the path to those files. This file can then be read on a second pass thus eliminating the need to process every file again after a read-only check to look for files with geotags. This file has the name <cwd>_geotagraw.lis where <cwd> is the current working directory. Re-running geotagraw will overwrite an existing version of this file.

Notes

Warning: This program will modify your files. Please make sure you have backups of your raw files before running this code. Existing geotags in the raw file will be overwritten and you will not be able to get them back! But then you do have a backup, right?

Currently only looks for Nikon .NEF, Sony .ARW and Canon .CR2 files.

Error checking hasn't been tested yet.

Rationale

Garmin Basecamp is great for viewing and editing my GPS tracks, and it's perfectly capable of using those tracks to geotag my photos. Alas, it only applies geotags to the JPGs, not the raw files...

Useful reading:

I found the following webpages useful when writing geotagraw:

License and copyright

This software is licensed under GPL-3.0+.

Copyright © 2016-2017 Andy Gibb