Transfer exif gps info from one image to another
Take a look at ExifTool. It is a swiss army knife of Exif info manipulation, can do what you need, among many other things. It is Windows/Linux/Mac compatible command-line tool and a Perl module as well. Free and open source:
The "-tagsFromFile" Option
A special ExifTool option allows copying tags from one file to another. The command-line syntax for doing this is "-tagsFromFile SRCFILE". Any tags specified after this option on the command line are extracted from source file and written to the destination file. If no tags are specified, then all writable tags are copied. This option is very simple, yet very powerful. Depending on the formats of the source and destination files, some of tags read may not be valid in the destination file, in which case they aren't written.
The following command will change all files in current directory and its children (recursively), copying all GPS-related tags from the file SOURCE.JPG
:
exiftool −overwrite_original_in_place -r -tagsFromFile SOURCE.JPG -gps:all .
Another way to do this is to put the following into a script. First parameter passed should be the file to copy GPS coordinates from, and all other parameters are the target files to be updated:
#!/usr/bin/env bash
lon=$(exiftool -s3 -GPSLongitude "$1")
lat=$(exiftool -s3 -GPSLatitude "$1")
exiftool -GPSLongitude="$lon" -GPSLatitude="$lat" "${@:2}"
Related videos on Youtube
Somebody still uses you MS-DOS
Just kidding. MS-DOS, you broke my heart. No more.
Updated on September 18, 2022Comments
-
Somebody still uses you MS-DOS over 1 year
I have a camera (not a cellphone) that inserts gps exif info into pictures.
Fact is: using the "gps on" all time drains the battery. So i thought: what about taking just one picture with gps on, and them at home add this exif info to the others?
I would like to know if there are applications that you know of that can help me in this scenario: having a photo with exif information about gps, copy this same gps info to a batch of another pictures.
(I prefer Linux/Mac solutions, but I accept windows as well. I don't mind if it's a command line application.)
-
Ƭᴇcʜιᴇ007 over 12 yearspossible duplicate of How do I batch change the date taken information in EXIF data? also see Editing JPEG EXIF properties
-
-
Somebody still uses you MS-DOS over 12 yearsI've read about it, but I'm going to need to script a lot of stuff (with bash, python, whatever). I was looking for something already done in the terms I asked.
-
Somebody still uses you MS-DOS over 12 years+1 @haimg, you're posting the options I can use really put into use. (But I'm still looking for something out of the box :)
-
MikeyB over 12 yearsjhead is another very useful utility that may complement ExifTool.
-
Somebody still uses you MS-DOS over 12 years@grawity: Does ${@:2} mean multiple arguments? If so, you solved my problem with SIX LINES!!
-
user1686 over 12 years@SomebodystillusesyouMS-DOS: All arguments (items in the
$@
array) starting with the 2nd. Also, it's four lines now that I realized that I put a lot of unnecessary (and incorrect) stuff there. (Also, "solved".) -
user1686 over 12 yearsWhile you're using the script, I'll keep facedesking over the fact that I totally missed the
tagsFromFile
option which could've done the same in one line... -
haimg over 12 years@grawity: I was a bit surprised by your edit :-)
-
Somebody still uses you MS-DOS over 12 years@grawity and @haimg:
exiftool −overwrite_original_in_place -r -tagsFromFile SOURCE.JPG -gps:all .
- the-r
option recurses into the directory (.
), and the-gps:all
, well... it's just what I was looking for. I beat you, grawity! :) I think you can edit this post and add this snippet, but remember to warn people to readexiftool --help
to understand the other options I gave... thank you all! -
Skeleton Bow almost 6 yearsThis seems to modify some other tags, such as
Jpg From Raw Start
,Strip Offsets
, andOther Image Start
. Should this be of any concern? -
wcochran over 2 yearsThe last bash script got lon = "84 deg 18' 5.42" W" but wrote "84 deg 18' 5.42" E" placing the image somewhere in china. I assume this is a double quote problem.
-
wcochran over 2 yearsActually this is a bug in
exiftool
. It reads "84 deg 18' 5.42" W" but writes "84 deg 18' 5.42" E". That is crappy. -
wcochran over 2 yearsAdded solution that bypasses and explains bug.