Hi,
I used to use GeoSetter on Windows but recently migrated to Mac, so now getting to grips with exiftool command line.
I tend to use three different cameras depending on the situation: iPhone 16, OM System TG-7 and Olympus E-M5. TG-7 has inbuilt GPS but often struggles to get a fix, E-M5 has no GPS. I often run the Olympus OI.Share app on my phone to then geotag photos, but sometimes forget.
In those cases where I end up with some photos having no geotag, I'd like interpolate from those images that have a location by creating a GPX file using inverse geocoding and using that to tag the missing pictures.
I had to modify the suggested gpx.fmt file as it wasn't writing a timestamp to the GPX output, changing gpsdatetime to datetimeoriginal fixed that. However now I am getting local time rather than UTC - how do I get it to write UTC time? The camera seems to have a correct OffsetTime tag. I am trying to simply subtract offset time but this isn't working:
#[BODY] <time>${datetimeoriginal#-OffsetTime#;DateFmt("%Y-%m-%dT%H:%M:%S%fZ")}</time>
I probably have the $ and # in the wrong places?
Thanks
papa_sierra
The necessary gymnastics is not for the faint of heart:
${datetimeoriginal#;my $tz=$self->GetValue("OffsetTimeOriginal");$tz=~tr/-+/+-/;ShiftTime($tz);DateFmt("%Y-%m-%dT%H:%M:%S%fZ")}
Here I used OffsetTimeOriginal instead of OffsetTime becaue this is the one that corresponds to DateTimeOriginal.
The GetValue method must be used to get the value of another tag from inside an advanced formatting expression. The ShiftTime helper function is used to shift the time, but first I had to change the sign by translating - to + and visa versa.
- Phil
Alternatively, you could go ahead and fix the GPS time stamps first. Assuming that OffsetTimeOriginal is set, you could use this
exiftool '-GPS*Stamp<SubSecDateTimeOriginal' /path/to/files/
Then you could use the unedited gpx.fmt file.
I like StarGeek's idea better.
- Phil
Thank you both for the quick and helpful replies!
To make sure I understand this syntax correctly:
exiftool '-GPS*Stamp<SubSecDateTimeOriginal' /path/to/files/
A few questions:
- Is the * in GPS*Stamp a clever way of changing both GPSDateStamp and GPSTimeStamp?
- What does SubSecDateTimeOriginal mean? Why not just DateTimeOriginal
- How do time zones come into this? Will the above command take them into account automatically, or will it set GPS time to local time unless I make a further adjustment?
Thanks & Best Regards
papa_sierra
Quote from: papa_sierra on October 29, 2024, 06:55:25 AM1. Is the * in GPS*Stamp a clever way of changing both GPSDateStamp and GPSTimeStamp?
Yes.
Quote2. What does SubSecDateTimeOriginal mean? Why not just DateTimeOriginal
See the Composite tags (https://exiftool.org/TagNames/Composite.html).
Quote3. How do time zones come into this? Will the above command take them into account automatically, or will it set GPS time to local time unless I make a further adjustment?
StarGeek's command will set GPSDateTime correctly as long as DateTimeOriginal and OffsetTimeOriginal exist in the file.
- Phil
Because I like to be complete, some more details for anyone who comes across this in the future
Quote from: papa_sierra on October 29, 2024, 06:55:25 AMIs the * in GPS*Stamp a clever way of changing both GPSDateStamp and GPSTimeStamp?
From the docs on the
-TAG[+-^]=[VALUE] option (https://exiftool.org/exiftool_pod.html#TAG---VALUE)
QuoteThe wildcards * and ? may be used in tag names to assign the same value to multiple tags.
QuoteWhat does SubSecDateTimeOriginal mean? Why not just DateTimeOriginal
There are three SubSec Composite tags(
SubSecCreateDate/
SubSecDateTimeOriginal/
SubSecModifyDate), one for each of the three main EXIF date/time tags. Because the EXIF date/time tags are split into three separate tags (main date/time, time zone, and subseconds), these three tags will combine the all three of the corresponding tags into a single value, which is useful for copying data, such as in this case.
Hi StarGeek, Phil,
Somehow I am still running into issues with this, which may be due to daylight savings time.
Have a look at this image taken with my Olympus camera during October in London, UK, at 07:13am local time (UTC+1). The time zone in the camera was not set correctly, so it got recorded as 08:13+02:
Create Date : 2024:10:18 08:13:32+02:00
Date/Time Original : 2024:10:18 08:13:32+02:00
Modify Date : 2024:10:18 08:13:32+02:00
After running the command suggested below, the GPS date/time is now as follows:
GPS Date/Time : 2024:10:18 07:13:32Z
Clearly this is incorrect by one hour. Do you have any suggestions what could be going on?
Best Regards
papa_sierra
Here is what I get when I write that value manually.
> exiftool a.jpg "-gps*stamp=2024:10:18 08:13:32+02:00"
1 image files updated
> exiftool a.jpg "-gps*stamp" -gpsdatetime -a -s -G1
[GPS] GPSTimeStamp : 06:13:32
[GPS] GPSDateStamp : 2024:10:18
[Composite] GPSDateTime : 2024:10:18 06:13:32Z
Make sure you are copying what you think you are copying. It looks like you copied from a date/time tag that didn't include a time zone. Use this command to see all of the available date/time tags, and use the appropriate one in your command:
exiftool -a -s -G1 -time:all FILE
- Phil
Quote from: papa_sierra on November 14, 2024, 11:35:35 AMAfter running the command suggested below, the GPS date/time is now as follows:
GPS Date/Time : 2024:10:18 07:13:32Z
Which command are you using?
Here's what I get with my command
C:\>exiftool -time:all --system:all -G1 -a -s y:\!temp\Test4.jpg
[ExifIFD] DateTimeOriginal : 2024:10:18 08:13:32
[ExifIFD] OffsetTimeOriginal : +02:00
[Composite] SubSecDateTimeOriginal : 2024:10:18 08:13:32+02:00
C:\>exiftool -P -overwrite_original "-GPS*Stamp<SubSecDateTimeOriginal" y:\!temp\Test4.jpg
1 image files updated
C:\>exiftool -time:all --system:all -G1 -a -s y:\!temp\Test4.jpg
[ExifIFD] DateTimeOriginal : 2024:10:18 08:13:32
[ExifIFD] OffsetTimeOriginal : +02:00
[GPS] GPSTimeStamp : 06:13:32
[GPS] GPSDateStamp : 2024:10:18
[Composite] SubSecDateTimeOriginal : 2024:10:18 08:13:32+02:00
[Composite] GPSDateTime : 2024:10:18 06:13:32Z
Thank you both for your reply.
Bizarrely, on rerunning, it is now correct. Between the new version and previous file, all timestamps are completely identical (incl. time zones), except that now the GPSTimeStamp is correct rather than 1h off.
Interestingly, Olympus provides a DateTimeUTC timestamp - it makes sense to use this and copy it to GPS*Stamp going forward.
Best
papa_sierra
OK, actually there is something weird going on.
Here are the original file time stamps (from another file, but with similar problem):
[System] FileModifyDate : 2024:10:18 13:34:20+01:00
[System] FileAccessDate : 2024:11:15 17:13:23+00:00
[System] FileInodeChangeDate : 2024:11:15 17:13:23+00:00
[IFD0] ModifyDate : 2024:10:18 12:34:20
[ExifIFD] DateTimeOriginal : 2024:10:18 12:34:20
[ExifIFD] CreateDate : 2024:10:18 12:34:20
[ExifIFD] OffsetTime : +03:00
[ExifIFD] OffsetTimeOriginal : +03:00
[ExifIFD] OffsetTimeDigitized : +03:00
[Olympus] DateTimeUTC : 2024:10:18 09:34:20
[Composite] SubSecCreateDate : 2024:10:18 12:34:20+03:00
[Composite] SubSecDateTimeOriginal : 2024:10:18 12:34:20+03:00
[Composite] SubSecModifyDate : 2024:10:18 12:34:20+03:00
Then I run the following command:
exiftool "-GPS*Stamp<DateTimeUTC" DIR
Then the timestamps look as follows:
[System] FileModifyDate : 2024:11:15 17:17:37+00:00
[System] FileAccessDate : 2024:11:15 17:17:43+00:00
[System] FileInodeChangeDate : 2024:11:15 17:17:43+00:00
[IFD0] ModifyDate : 2024:10:18 12:34:20
[ExifIFD] DateTimeOriginal : 2024:10:18 12:34:20
[ExifIFD] CreateDate : 2024:10:18 12:34:20
[ExifIFD] OffsetTime : +03:00
[ExifIFD] OffsetTimeOriginal : +03:00
[ExifIFD] OffsetTimeDigitized : +03:00
[Olympus] DateTimeUTC : 2024:10:18 09:34:20
[GPS] GPSTimeStamp : 09:34:20
[GPS] GPSDateStamp : 2024:10:18
[Composite] SubSecCreateDate : 2024:10:18 12:34:20+03:00
[Composite] SubSecDateTimeOriginal : 2024:10:18 12:34:20+03:00
[Composite] SubSecModifyDate : 2024:10:18 12:34:20+03:00
[Composite] GPSDateTime : 2024:10:18 09:34:20Z
Then I geotag:
exiftool -api GeoMaxIntSecs=10000 -api GeoMaxExtSecs=10000 -if 'not $GPSLatitude' -overwrite_original -geotag GPXFILE DIR
After geotagging, this is what it looks like:
[System] FileModifyDate : 2024:11:15 17:19:20+00:00
[System] FileAccessDate : 2024:11:15 17:19:21+00:00
[System] FileInodeChangeDate : 2024:11:15 17:19:21+00:00
[IFD0] ModifyDate : 2024:10:18 12:34:20
[ExifIFD] DateTimeOriginal : 2024:10:18 12:34:20
[ExifIFD] CreateDate : 2024:10:18 12:34:20
[ExifIFD] OffsetTime : +03:00
[ExifIFD] OffsetTimeOriginal : +03:00
[ExifIFD] OffsetTimeDigitized : +03:00
[Olympus] DateTimeUTC : 2024:10:18 09:34:20
[GPS] GPSTimeStamp : 11:34:20
[GPS] GPSDateStamp : 2024:10:18
[Composite] SubSecCreateDate : 2024:10:18 12:34:20+03:00
[Composite] SubSecDateTimeOriginal : 2024:10:18 12:34:20+03:00
[Composite] SubSecModifyDate : 2024:10:18 12:34:20+03:00
[Composite] GPSDateTime : 2024:10:18 11:34:20Z
Why does the -geotag command modify the GPS time?
Best Regards
papa_sierra
The -geotag option writes all GPS tags, including GPSDateStamp and GPSTimeStamp based on the value from DateTimeOriginal by default, but you may specify GPSDateTime instead if you want. Read here for details (https://exiftool.org/geotag.html#geotime).
- Phil
First, remove the -api calls. If you run the command again, you will probably get a an error of some sort, probably "No writable tags set".
With those -api settings, you have allowed for the time stamps to be off by 2 hours, 46 minutes. When you don't include the -Geotime, exiftool will default to the DateTimeOriginal and use the local time zone, which is different than the time zone you actually want to use.
After you remove the -api options, add
"-Geotime<DateTimeUTC"
Edit: Or maybe it should be this, test it out (change double quotes to single quotes on Mac/Linux)
"-Geotime<$DateTimeUTC+00:00"
Quote from: StarGeek on November 15, 2024, 12:34:56 PMEdit: Or maybe it should be this, test it out (change double quotes to single quotes on Mac/Linux)
"-Geotime<$DateTimeUTC+00:00"
yes.
Thank you, the various timestamps finally work.
The reason I am including the api settings with 10000 seconds is that the photos were taking on a 4-hour flight with large (2h+) gaps between GPS fixes. I'd like to interpolate position between valid fixes. Do these api calls not achieve that?
Best Regards
papa_sierra
Quote from: papa_sierra on November 16, 2024, 04:50:53 AMI'd like to interpolate position between valid fixes. Do these api calls not achieve that?
They do, but as you've seen, it covers up the error when the incorrect UTC/time zone is used. But that should be fixed now.