exiftool -AllDates doesn't update GPS date and/or time

Started by Sadi, March 04, 2021, 06:55:02 AM

Previous topic - Next topic

Sadi

Hi, I'm using exiftool under Kubuntu 20.10 (libimage-exiftool-perl package version 12.05-1 (groovy) and have a problem handling GPSDateStamp, GPSTimeStamp  and GPSDateTime tags.
The simplest solution to fix issues with date and time tags (especially needed in the case of images/videos from different devices) seems using the option -AllDates-="0:0:0 7:0:0" or -AllDates+="0:0:0 7:0:0".
However, this doesn't seem to have any effect on the corresponding GPS tags.
For example, when a 7-hour shift as above can smartly change the date tags as well as time tags, but makes no change in GPS date/time tags.

I wonder if this is a bug or a feature missing.
If the latter is true, I'd appreciate very much a suggestion to change GPS date/time tags also in accordance with any change in the other date/time tags.

StarGeek

Quote from: Sadi on March 04, 2021, 06:55:02 AM
The simplest solution to fix issues with date and time tags (especially needed in the case of images/videos from different devices) seems using the option -AllDates-="0:0:0 7:0:0" or -AllDates+="0:0:0 7:0:0".
However, this doesn't seem to have any effect on the corresponding GPS tags.

If you check the Shortcut tags page, you'll see that AllDates is a shortcut for the three most commonly used EXIF timestamps, CreateDate, DateTimeOriginal, and ModifyDate.  It does not affect any other tag.

The GPS timestamps can be tricky because the date and time are in separate tags and if you try to shift the time into a new date, it will only affect the time and the date will not change.  The XMP:GPSDateTime tag does hold both date and time, so that can be shifted properly.

I think this will work, test it out first
exiftool -GlobalTimeShift -7 -TagsFromFile @ -Time:all "-GPSDateStamp<GPSDateTime" "-GPSTimeStamp<GPSDateTime" /path/to/files/
* 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).

Sadi

Quote from: StarGeek on March 04, 2021, 11:00:57 AM
I think this will work, test it out first
exiftool -GlobalTimeShift -7 -TagsFromFile @ -Time:all "-GPSDateStamp<GPSDateTime" "-GPSTimeStamp<GPSDateTime" /path/to/files/

This works perfectly; thank you very much!
However, I've encountered a problem implementing it in a full timestamp format (it seems I shouldn't be using it like that):
exiftool -GlobalTimeShift "-1:2:3 4:5:6" -TagsFromFile @ -Time:all "-GPSDateStamp<GPSDateTime" "-GPSTimeStamp<GPSDateTime" "image.jpg" -overwrite_original
It seems it can be used for shifting the time globally in h:m:s format (e.g. "-4:5:6"), even if such a shift causes a change in the date, but it can't be used for shifting the time globally in y:m:d h:m:s format.
I wonder if there is a way for this as well...

StarGeek

Quote from: Sadi on March 05, 2021, 08:15:14 AM
However, I've encountered a problem implementing it in a full timestamp format (it seems I shouldn't be using it like that):
exiftool -GlobalTimeShift "-1:2:3 4:5:6" -TagsFromFile @ -Time:all "-GPSDateStamp<GPSDateTime" "-GPSTimeStamp<GPSDateTime" "image.jpg" -overwrite_original
It seems it can be used for shifting the time globally in h:m:s format (e.g. "-4:5:6"), even if such a shift causes a change in the date, but it can't be used for shifting the time globally in y:m:d h:m:s format.
I wonder if there is a way for this as well...

In what way is it not working for you?  What is the exact command?
It seems to work correctly here
C:\>exiftool -time:all --system:all -g1 -a -s y:\!temp\Test4.jpg
---- IFD0 ----
ModifyDate                      : 2021:03:05 07:47:28
---- ExifIFD ----
DateTimeOriginal                : 2021:03:05 07:47:28
CreateDate                      : 2021:03:05 07:47:28
---- GPS ----
GPSTimeStamp                    : 15:47:28
GPSDateStamp                    : 2021:03:05
---- XMP-exif ----
GPSDateTime                     : 2021:03:05 07:47:28-08:00
---- Composite ----
GPSDateTime                     : 2021:03:05 15:47:28Z

C:\>exiftool -P -overwrite_original -GlobalTimeShift "-1:2:3 4:5:6" -TagsFromFile @ -Time:all "-GPSDateStamp<GPSDateTime" "-GPSTimeStamp<GPSDateTime" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -time:all --system:all -g1 -a -s y:\!temp\Test4.jpg
---- IFD0 ----
ModifyDate                      : 2020:01:02 03:42:22
---- ExifIFD ----
DateTimeOriginal                : 2020:01:02 03:42:22
CreateDate                      : 2020:01:02 03:42:22
---- GPS ----
GPSTimeStamp                    : 11:42:22
GPSDateStamp                    : 2020:01:02
---- XMP-exif ----
GPSDateTime                     : 2020:01:02 11:42:22Z
---- Composite ----
GPSDateTime                     : 2020:01:02 11:42:22Z
* 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).

Sadi

Quote from: StarGeek on March 05, 2021, 10:55:35 AM
In what way is it not working for you?  What is the exact command?

I had worse results before (in the date part only), but this time I started with a fresh and clean jpg file, and got the following two results, which show that it works smoothly only when a change in the time part doesn't cause a change in the date part:

exiftool -time:all --system:all -g1 -a -s test.jpg

---- IFD0 ----
ModifyDate                      : 2021:01:01 12:12:12
---- ExifIFD ----
DateTimeOriginal                : 2021:01:01 12:12:12
CreateDate                      : 2021:01:01 12:12:12
---- GPS ----
GPSTimeStamp                    : 09:12:12
GPSDateStamp                    : 2021:01:01
---- IPTC ----
DateCreated                     : 2021:01:01
TimeCreated                     : 12:12:12+03:00
---- XMP-pdf ----
CreationDate                    : 2021:01:01 12:12:12+03:00
---- Composite ----
GPSDateTime                     : 2021:01:01 09:12:12Z
DateTimeCreated                 : 2021:01:01 12:12:12+03:00

exiftool -GlobalTimeShift "+01:01:01 10:10:10" -TagsFromFile @ -Time:all "-GPSDateStamp<GPSDateTime" "-GPSTimeStamp<GPSDateTime" "test.jpg"
exiftool -time:all --system:all -g1 -a -s test.jpg

---- IFD0 ----
ModifyDate                      : 2022:02:02 22:22:22
---- ExifIFD ----
DateTimeOriginal                : 2022:02:02 22:22:22
CreateDate                      : 2022:02:02 22:22:22
---- GPS ----
GPSTimeStamp                    : 19:22:22
GPSDateStamp                    : 2022:02:02
---- IPTC ----
DateCreated                     : 2021:01:01
TimeCreated                     : 12:12:12+03:00
---- XMP-pdf ----
CreationDate                    : 2022:02:02 22:22:22+03:00
---- XMP-photoshop ----
DateCreated                     : 2021:01:01
---- Composite ----
GPSDateTime                     : 2022:02:02 19:22:22Z
DateTimeCreated                 : 2021:01:01 12:12:12+03:00

exiftool -GlobalTimeShift "+01:11:01 02:38:39" -TagsFromFile @ -Time:all "-GPSDateStamp<GPSDateTime" "-GPSTimeStamp<GPSDateTime" "test.jpg"
exiftool -time:all --system:all -g1 -a -s test.jpg

---- IFD0 ----
ModifyDate                      : 2024:01:07 01:01:01
---- ExifIFD ----
DateTimeOriginal                : 2024:01:07 01:01:01
CreateDate                      : 2024:01:04 01:01:01
---- GPS ----
GPSTimeStamp                    : 22:01:01
GPSDateStamp                    : 2024:01:06
---- IPTC ----
DateCreated                     : 2022:12:02
TimeCreated                     : 12:12:12+03:00
---- XMP-pdf ----
CreationDate                    : 2024:01:07 01:01:01+03:00
---- XMP-photoshop ----
DateCreated                     : 2022:12:02
---- Composite ----
GPSDateTime                     : 2024:01:06 22:01:01Z
DateTimeCreated                 : 2022:12:02 12:12:12+03:00


I think, in the second operation, 2022:02:02 22:22:22 +01:11:01 02:38:39 should be 2024:01:04 01:01:01 and not 2024:01:07 01:01:01

StarGeek

Quote from: Sadi on March 06, 2021, 05:03:00 PM
I think, in the second operation, 2022:02:02 22:22:22 +01:11:01 02:38:39 should be 2024:01:04 01:01:01 and not 2024:01:07 01:01:01

Yeah, that should be the correct timeestamp.  I faintly recall there being an explanation for some oddities, but can't find it right now.  Hopefully Phil will weigh in on this.

One thing to fix is the IPTC timestamps.  They have the same problem as the GPS timestamps in that they are split into two tags.  So a similar solution is required
"-IPTC:DateCreated<DateTimeCreated" "-IPTC:TimeCreated<DateTimeCreated"
* 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).

Sadi

Quote from: StarGeek on March 06, 2021, 06:02:00 PM
I faintly recall there being an explanation for some oddities, but can't find it right now.  Hopefully Phil will weigh in on this.

OK, thanks a lot.

When I tried again on a new jpg file containing exif header created from scratch, and entered
exiftool -P -overwrite_original -GlobalTimeShift "+01:01:01 10:10:10" -TagsFromFile @ -Time:all "-GPSDateStamp<GPSDateTime" "-GPSTimeStamp<GPSDateTime" "test.jpg" and exiftool -P -overwrite_original -GlobalTimeShift "+01:11:01 02:38:39" -TagsFromFile @ -Time:all "-GPSDateStamp<GPSDateTime" "-GPSTimeStamp<GPSDateTime" "test.jpg" consecutively, this time the command exiftool -time:all --system:all -g1 -a -s "test.jpg" gave me this result (day now is 04), which is good enough for me:

---- IFD0 ----
ModifyDate                      : 2024:01:04 01:01:01
---- ExifIFD ----
DateTimeOriginal                : 2024:01:04 01:01:01
CreateDate                      : 2024:01:04 01:01:01
---- GPS ----
GPSTimeStamp                    : 22:01:01
GPSDateStamp                    : 2024:01:03
---- IPTC ----
DateCreated                     : 2022:12:02
TimeCreated                     : 12:12:12+03:00
---- XMP-pdf ----
CreationDate                    : 2024:01:04 01:01:01+03:00
---- XMP-photoshop ----
DateCreated                     : 2022:12:02
---- Composite ----
GPSDateTime                     : 2024:01:03 22:01:01Z
DateTimeCreated                 : 2022:12:02 12:12:12+03:00


And I've got it all right with: exiftool -P -overwrite_original -GlobalTimeShift "+01:01:01 10:10:10" -TagsFromFile @ -Time:all "-GPSDateStamp<GPSDateTime" "-GPSTimeStamp<GPSDateTime" "-IPTC:DateCreated<DateTimeCreated" "-IPTC:TimeCreated<DateTimeCreated" "-XMP:DateCreated<DateTimeCreated" "test.jpg"

StarGeek

The problem I faintly recall was with how exiftool deals with month and years, because of variable number of days, 365-366 for years/leap years, 28-31 for months.  If you can reduce the shift to just days, it's less of a problem.

Of course I could be completely wrong and my mind is playing tricks on me in my old age ;)
* 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).

Phil Harvey

This is of course a hypothetical case, and nobody should be shifting date/time values like this.

Example:  If you apply a shift of 1 month and 2 days from February 28, do you get March 30, or April 1, or April 2?  The answer depends on whether you apply the month shift or the day shift first, and whether or not it was a leap year.  All three answers are possible.

- 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 ($).