GPS Timestamping issues

Started by bram, December 22, 2020, 03:59:16 AM

Previous topic - Next topic

bram

Hi,

I received some pictures accompanied with xmp-files containing metadata. A short fragment of the GPS-related data in one of the xmp-files (file1.xmp):

exif:DateTimeOriginal="2015-07-20T06:59:03+07:00"
exif:GPSLatitude="17,28.138151N"
exif:GPSLongitude="106,35.990252E"
exif:GPSMapDatum="WGS-84"
exif:GPSTimeStamp="2015-07-20T06:59:03Z"
exif:GPSVersionID="2.2.0.0"


When I import and export this file in Lightroom, the GPSDateTime seems to be off. This makes sense, as the GPSTimeStamp shows a wrong UTC timestamp. I tried to correct this, by using the following command:

exiftool.exe "-xmp:GPSDateTime<DateTimeOriginal" file1.xmp


This had following result:

<exif:GPSTimeStamp>2015-07-20T06:58:51+07:00</exif:GPSTimeStamp>


This information seems correct, but after importing and exporting with Lightroom, the GPS timestamp is not correct anymore. It seems that Lightroom expects a UTC date in the GPSTimeStamp field.

With another file, I don't have this issue. Here's the XMP-fragment (file2.xmp):

exif:DateTimeOriginal="2015-07-19T20:11:04+07:00"
exif:GPSAltitude="214/5"
exif:GPSAltitudeRef="0"
exif:GPSLatitude="20,14.525772N"
exif:GPSLongitude="105,58.470923E"
exif:GPSMapDatum="WGS-84"
exif:GPSTimeStamp="2015-07-19T13:11:04Z"
exif:GPSVersionID="2.2.0.0"


The difference is that the GPSTimeStamp in the first file (not working correctly) is written with timezone information, in the second file (working correctly) the GPSTimeStamp is written in UTC.
Is there a way to put a correct UTC time in the GPSTimeStamp field? (I attached both xmp-files.)

Kind regards,
Bram

Phil Harvey

To write UTC time to GPSDateTime try this:

exiftool "-xmp:GPSDateTime<${DateTimeOriginal;s/[-+].*//}Z" -globalTimeShift -7 file1.xmp

Of course, this will only be correct if the time zone is +07:00.  It would be more complicated to allow a variable time zone.

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

Phil Harvey

OK.  This version shifts the time according to the time zone in DateTimeOriginal:

exiftol "xmp:GPSDateTime<${datetimeoriginal;s/([-+].*)//;my $tz=$1;$tz=~tr/-+/+-/;ShiftTime($tz)}Z" file1.xmp

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

bram

Hi Phil,

Thanks for the answer. I understand how you're trying to achieve it. However, it does not work for me. See output below...


>exiftool.exe "-xmp:GPSDateTime" "-DateTimeOriginal" file1.xmp
GPS Date/Time                   : 2015:07:20 06:59:03Z
Date/Time Original              : 2015:07:20 06:59:03+07:00

>exiftool.exe "-xmp:GPSDateTime<${DateTimeOriginal;s/([-+].*)//;my $tz=$1;$tz=~tr/-+/+-/;ShiftTime($tz)}Z" file1.xmp
    1 image files updated

>exiftool.exe "-xmp:GPSDateTime" "-DateTimeOriginal" file1.xmp
GPS Date/Time                   : 2015:07:20 06:59:03Z
Date/Time Original              : 2015:07:20 06:59:03+07:00


Am I doing something wrong?

Phil Harvey

You must be using a really old version of ExifTool.  The current version is 12.12.

Here is what I get. (I need to use single quotes in one of the commands because I'm on a Mac)

> exiftool "-xmp:GPSDateTime" "-DateTimeOriginal" file1.xmp
GPS Date/Time                   : 2015:07:20 06:59:03Z
Date/Time Original              : 2015:07:20 06:59:03+07:00
> exiftool '-xmp:GPSDateTime<${DateTimeOriginal;s/([-+].*)//;my $tz=$1;$tz=~tr/-+/+-/;ShiftTime($tz)}Z' file1.xmp
    1 image files updated
> exiftool "-xmp:GPSDateTime" "-DateTimeOriginal" file1.xmp
GPS Date/Time                   : 2015:07:19 23:59:03Z
Date/Time Original              : 2015:07:20 06:59:03+07:00


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

bram

Hi Phil,

I updated to the latest version (I was stil on 10.9.6.0) and now it indeed works.

Thanks a lot for the effort  :) .

Kind regards,
Bram