Correct / add GPS info

Started by blinnen99, June 25, 2021, 10:48:35 AM

Previous topic - Next topic

blinnen99

Hi,
at first, sorry for my bad English.

In April 2019 a GPS week number rollover took place but the GPS unit I'm using on my camera cannot be fixed and, as a result, since then all the pictures have a date which is 7168 days back.
Is there any way with exiftool to update the GPSDateStamp tag in one and/or in all the pictures in a folder by adding 7168 days?
I tried with the option -geosync=+"7168 00:00:00" on a single file but it seems not to be the right one as the program says 0 image files updated/1 image files unchanged.

Also is there any way to copy all the gps tags from one picture to another one (or to all the pictures in a folder) excluding GPSDateStamp and GPSTimeStamp?
The -gps=all option copies gps date/time tags too but I'd preffer to leave them empty on the target picture or, better, if it is possible to fill them in by using the creation date/time of the target picture itself.

I'm using Windows 10.

Thanks and best regards
Luigi

StarGeek

Quote from: blinnen99 on June 25, 2021, 10:48:35 AM
Is there any way with exiftool to update the GPSDateStamp tag in one and/or in all the pictures in a folder by adding 7168 days?
I tried with the option -geosync=+"7168 00:00:00" on a single file...

The Geosync option only affects the timing when you are tagging images from a GPS track.  It doesn't write any data by itself.

Since you just need to update the date and not the time, you just need to shift the GPSDateStamp tag, maybe the XMP:GPSDateTime tag if it exists.  It would be more complex if you needed to update the time portion, but since you don't need to do that, you could run this command to update all the files in batch.  Be careful not to update files that don't need it, of course.
exiftool -GPSDateStamp+="7168 00:00:00" -GPSDateTime+="7168 00:00:00" /path/to/files/

Example output.  The time portion stays the same, but the date is shifted by about 20 years
C:\>exiftool -g1 -a -s -gps* y:\!temp\Test4.jpg
---- GPS ----
GPSVersionID                    : 2.3.0.0
GPSTimeStamp                    : 15:37:40
GPSDateStamp                    : 2021:06:25
---- Composite ----
GPSDateTime                     : 2021:06:25 15:37:40Z

C:\>exiftool -P -overwrite_original -GPSDateStamp+="7168 00:00:00" -GPSDateTime+="7168 00:00:00" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -gps* y:\!temp\Test4.jpg
---- GPS ----
GPSVersionID                    : 2.3.0.0
GPSTimeStamp                    : 15:37:40
GPSDateStamp                    : 2041:02:08
---- Composite ----
GPSDateTime                     : 2041:02:08 15:37:40Z



QuoteAlso is there any way to copy all the gps tags from one picture to another one (or to all the pictures in a folder) excluding GPSDateStamp and GPSTimeStamp?

You could do this
exiftool -TagsFromFile /path/to/sourcefile/ -gps* -XMP:gps* --GPS*Stamp --GPSDateTime /path/to/targets/

Example output
C:\>exiftool -G1 -a -s -gps* y:\!temp\Test4.jpg
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 40 deg 41' 21.12"
[GPS]           GPSTimeStamp                    : 15:50:16
[GPS]           GPSDateStamp                    : 2021:06:25
[XMP-exif]      GPSLongitude                    : 74 deg 2' 40.20" W
[XMP-exif]      GPSDateTime                     : 2021:06:25 08:50:16-07:00
[Composite]     GPSDateTime                     : 2021:06:25 15:50:16Z
[Composite]     GPSLatitude                     : 40 deg 41' 21.12" N
[Composite]     GPSLongitudeRef                 : West
[Composite]     GPSPosition                     : 40 deg 41' 21.12" N, 74 deg 2' 40.20" W

C:\>exiftool -P -overwrite_original -TagsFromFile y:\!temp\Test4.jpg -gps* -xmp:gps* --GPS*Stamp --GPSDateTime y:\!temp\Test3.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -gps* y:\!temp\Test3.jpg
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 40 deg 41' 21.12"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 74 deg 2' 40.20"
[XMP-exif]      GPSLongitude                    : 74 deg 2' 40.20" W
[Composite]     GPSLatitude                     : 40 deg 41' 21.12" N
[Composite]     GPSLongitude                    : 74 deg 2' 40.20" W
[Composite]     GPSLongitudeRef                 : West
[Composite]     GPSPosition                     : 40 deg 41' 21.12" N, 74 deg 2' 40.20" W


This is possibly a bit more complex than it needs to be because I don't know if you are writing the XMP GPS tags or not.  In the first image, the GPSLatitude and GPSLatitudeRef tags, which are part of the EXIF block, are filled out but the GPSLongitude is not.  Instead, the XMP:GPSLongitude is filled.  Both the EXIF and XMP GPS time tags have values.  The image that is the target of the copy now has both EXIF GPS coordinates filled out and the original GPSLongitude copied as well, but the GPS timestamps have not been copied.

Quotebetter, if it is possible to fill them in by using the creation date/time of the target picture itself.

This may or may not be possible depending upon what tag you are using for the "creation date/time".  If you are using the embedded EXIF time tag, such as CreateDate or DateTimeOriginal, then you would also need to include the time zone to shift it properly to UTC, because GPS timestamps need to be in UTC.  For example, for my timezone of -07:00, I could do this
exiftool "-GPS*Stamp<${DateTimeOriginal}-07:00" /path/to/files/

If you wanted to use the filesystem timestamps such as FileCreateDate or FileModifyDate, those automatically include the timezone, so you could use this
exiftool "-GPS*Stamp<FileModifyDate" /path/to/files/

All of this assumes that you are editing images.  If you are editing videos, it will not be possible to edit most of the data.  Some videos have embedded EXIF data and GPS tracks.  There is no standard for this type of data in a video files and every camera company does it in a different way, so these cannot be changed.  Most of the other data in videos can be changed, see the Quicktime tags page and search on these forums for more info.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

blinnen99

Hi,
thanks a lot for the very quick and detailed answer!

Quote from: StarGeek on June 25, 2021, 12:12:38 PM
The Geosync option only affects the timing when you are tagging images from a GPS track.  It doesn't write any data by itself.

Since you just need to update the date and not the time, you just need to shift the GPSDateStamp tag, maybe the XMP:GPSDateTime tag if it exists.  It would be more complex if you needed to update the time portion, but since you don't need to do that, you could run this command to update all the files in batch.  Be careful not to update files that don't need it, of course.
exiftool -GPSDateStamp+="7168 00:00:00" -GPSDateTime+="7168 00:00:00" /path/to/files/

This works exactely as needed, thanks!

Quote
You could do this
exiftool -TagsFromFile /path/to/sourcefile/ -gps* -XMP:gps* --GPS*Stamp --GPSDateTime /path/to/targets/

This is possibly a bit more complex than it needs to be because I don't know if you are writing the XMP GPS tags or not.  In the first image, the GPSLatitude and GPSLatitudeRef tags, which are part of the EXIF block, are filled out but the GPSLongitude is not.  Instead, the XMP:GPSLongitude is filled.  Both the EXIF and XMP GPS time tags have values.  The image that is the target of the copy now has both EXIF GPS coordinates filled out and the original GPSLongitude copied as well, but the GPS timestamps have not been copied.

No, right now I'm not using XMP GPS tags but Latitude and Longitude are both present in the EXIF tags; I guess I might therefore remove the -xmp:gps* but your command works even with that option.
Now in the source file properties (from windows explorer)  I see as Latitude "45; 29.1509; 0" while in the target now I see "45; 29; 9.054" but I suppose it is just a data format matter, right?

Quote
This may or may not be possible depending upon what tag you are using for the "creation date/time".  If you are using the embedded EXIF time tag, such as CreateDate or DateTimeOriginal, then you would also need to include the time zone to shift it properly to UTC, because GPS timestamps need to be in UTC.  For example, for my timezone of -07:00, I could do this
exiftool "-GPS*Stamp<${DateTimeOriginal}-07:00" /path/to/files/

If you wanted to use the filesystem timestamps such as FileCreateDate or FileModifyDate, those automatically include the timezone, so you could use this
exiftool "-GPS*Stamp<FileModifyDate" /path/to/files/

I guess DateTimeOriginal is more reliable since file creation might be affected by import process ... therefore, in my case (normally UTC+1), I guess I have to consider even daylight saving if active, right?
So exiftool "-GPS*Stamp<${DateTimeOriginal}+02:00" /path/to/files/

Last question: I guess no but does it make any difference when working on NEF and JPG files?

Thanks again!

StarGeek

Quote from: blinnen99 on June 25, 2021, 03:42:30 PM
No, right now I'm not using XMP GPS tags but Latitude and Longitude are both present in the EXIF tags; I guess I might therefore remove the -xmp:gps* but your command works even with that option.

Yep, that's why it was a bit more than might be needed.  So it would work either way.

QuoteNow in the source file properties (from windows explorer)  I see as Latitude "45; 29.1509; 0" while in the target now I see "45; 29; 9.054" but I suppose it is just a data format matter, right?

Yep, same number, formatted differently.  Using the -n (--printConv) option returns the same decimal number.  Here I set the EXIF GPSLatitude to the first number and the XMP GPSLatitude to the second number and then view the output.
C:\Programs\My_Stuff>exiftool -P -overwrite_original -all= -gpsLatitude="45; 29.1509; 0" -xmp:gpslatitude="45; 29; 9.054" y:\!temp\Test4.jpg
    1 image files updated

C:\Programs\My_Stuff>exiftool -g1 -a -s -gpslat* y:\!temp\Test4.jpg  -n
---- GPS ----
GPSLatitude                     : 45.4858483333333
---- XMP-exif ----
GPSLatitude                     : 45.4858483333333



QuoteI guess DateTimeOriginal is more reliable since file creation might be affected by import process ... therefore, in my case (normally UTC+1), I guess I have to consider even daylight saving if active, right?
So exiftool "-GPS*Stamp<${DateTimeOriginal}+02:00" /path/to/files/

Yes, you have to adjust for Daylight savings.

QuoteLast question: I guess no but does it make any difference when working on NEF and JPG files?

For these commands, there shouldn't be any difference.  With NEFs and other RAW filetypes, you need to be careful when editing EXIF data (see FAQ #8) but editing IPTC IIM and XMP data will not otherwise affect a RAW file type.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

blinnen99

Quote from: StarGeek on June 25, 2021, 08:24:31 PM

Thanks!
Just a final question:

QuoteYep, same number, formatted differently.  Using the -n (--printConv) option returns the same decimal number.  Here I set the EXIF GPSLatitude to the first number and the XMP GPSLatitude to the second number and then view the output.
C:\Programs\My_Stuff>exiftool -P -overwrite_original -all= -gpsLatitude="45; 29.1509; 0" -xmp:gpslatitude="45; 29; 9.054" y:\!temp\Test4.jpg
    1 image files updated

C:\Programs\My_Stuff>exiftool -g1 -a -s -gpslat* y:\!temp\Test4.jpg  -n
---- GPS ----
GPSLatitude                     : 45.4858483333333
---- XMP-exif ----
GPSLatitude                     : 45.4858483333333


I see they are exactly the same but, just to have the same format in files geotagged by the GPS unit and in those where I'm copying gps info, is there any way to include in the command line exiftool -TagsFromFile /path/to/sourcefile/ -gps* -XMP:gps* --GPS*Stamp --GPSDateTime /path/to/targets/ an option to write tags in the target file with the same format used in the source file?
-n option doesn't seem to work here, unless I used it in the wrong position.

Thanks again!

StarGeek

I don't believe there is an option to do so.  The way the GPS coordinates are stored is as 3 fractional values, one each for degrees, minutes, and seconds.  In the case of the first number, it is using a decimal value for the minutes when that decimal should actually be the seconds.  Exiftool is simplifying the fractions and writing them correctly. 

You can use the -v (-verbose) option to see the actual details of the GPS coordinates.  Using -v2 will display the fractional values and -v3 will include a hex dump, shown here
  | | 1)  GPSLatitude = 45 29 9.054 (45/1 29/1 4527/500)
  | |     - Tag 0x0002 (24 bytes, rational64u[3]):
  | |         0090: 00 00 00 2d 00 00 00 01 00 00 00 1d 00 00 00 01 [...-............]
  | |         00a0: 00 00 11 af 00 00 01 f4                         [........]
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).