behaviour in handling of date/time calculations in command line

Started by Harry356, December 05, 2018, 05:48:57 AM

Previous topic - Next topic

Harry356

Hi,

I'm new in this forum and found the following behaviour:

To have GPS tagged images sorted properly (strictly by time) in Photos for Mac the GPS:GPSDateStamp and GPS:GPSTimestamp tag need to be set and set to a value that makes sense in relation to the timezone the pictures where taken in and the GPS coordinates indicate (long and cumbersome testing lead to finding this ...).

For some reason (presumable an iPhone not having GPS reception while taking some pictures and using old values for GPSDate/TimeStamp) I recently had a few pictures not having these two GPS tags set properly (2 to 3 hrs off) for the timezone of Hawaii.

After some experimenting I came with the following fix:

exiftool "-gps:gpstimestamp<exif:DateTimeOriginal" "-gps:gpsdatestamp<exif:DateTimeOriginal"  example.jpg

works nicely in copying the date portion of DateTimeOriginal to GPSDateStamp and the time portion to GPSTimeStamp - OK!

the to set these values to the timezone of Hawaii (all for Photos on Mac the recognise the timezone) I try to shift the GPS date/time (normally coming from the satellites) by +10:00 hrs (UTC) by

exiftool "-gps:gpstimestamp+=10:00:00" "-gps:gpsdatestamp+=0000:00:00 10:00:00" example.jpg

which works as long as DateTimeOriginal is not past 14:00:00 - i.e. result is past midnight and thus the date should be day+1

Is this a bug in the date/time handling or intended behaviour?

I'm on a Mac and the exiftool version is 11.20 - thanks in advance for dealing with this - regards from Vienna/Austria,

Harry

P.S.: thanks for keeping up the excellent work on exiftool - I think the workflow of those caring for metadata in pictures would be next to impossible without it ...

Phil Harvey

Hi Harry,

Properly handling the date rollover is not possible with separate date and time tags.  The trick is to shift the date/time value before it is split into the separate GPS date and time tags:

exiftool "-gps:gpstimestamp<exif:DateTimeOriginal" "-gps:gpsdatestamp<exif:DateTimeOriginal" -api globaltimeshift=10:00 example.jpg

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).


StarGeek

Another option (which satisfies my obsession to have complete metadata) would be to add the time zone to the metadata and use the relevant tag.   For example, if you set the time zone on EXIF:OffsetTimeOriginal, you could then use the composite tag SubSecDateTimeOriginal

exiftool "-gps:gpstimestamp<SubSecDateTimeOriginal" "-gps:gpsdatestamp<SubSecDateTimeOriginal" example.jpg

And exiftool will set the GPS values properly to account for the date shift.

Example:
C:\>exiftool -g1 -a -s -exif:DateTimeOriginal -OffsetTimeOriginal -SubSecDateTimeOriginal y:\!temp\Test4.jpg
---- ExifIFD ----
DateTimeOriginal                : 2018:12:05 14:43:38
OffsetTimeOriginal              : -10:00
---- Composite ----
SubSecDateTimeOriginal          : 2018:12:05 14:43:38-10:00

C:\>exiftool -P -overwrite_original "-gps:gpstimestamp<SubSecDateTimeOriginal" "-gps:gpsdatestamp<SubSecDateTimeOriginal" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -gpsdatestamp -gpstimestamp y:\!temp\Test4.jpg
---- GPS ----
GPSTimeStamp                    : 00:43:38
GPSDateStamp                    : 2018:12:06
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

Quote from: StarGeek on December 05, 2018, 11:57:16 AM
if you set the time zone on EXIF:OffsetTimeOriginal, you could then use the composite tag SubSecDateTimeOriginal

I like this solution better, especially if you are dealing with multiple time zones.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).