Time parsing for GPSTimeStamp

Started by Archive, May 12, 2010, 08:54:13 AM

Previous topic - Next topic

Archive

[Originally posted by eam on 2007-12-12 21:58:14-08]

Hi, trying to set the xmp values and gps times based on the datetimeoriginal being in loacl time and specifing the timezone.  I have set up a number of user defined functions to provide the UTC time from the local datetimeoriginal so for example with a photo taken in the UTC+2 timezone I am using the following commands:
Code:
exiftool "-all>xmp:all" -F -d "%Y:%m:%d %H:%M:%S+0200" test.jpg
Code:
exiftool "-DateTimeOriginal-02>gpstimestamp" "-DateTimeOriginal-02>gpsdatestamp"  "-DateTimeOriginal-02>xmp:gpsdatetime" -F test.jpg
where the datetimeoriginal value for a particular photo is 2007:08:02 18:33:44+02:00

Problem is that after the first command, everything looks ok, with the XMP:Datetimeoriginal now containing the UTC offset as desired, and no value in the xmp:gpsdatetime field, however after the second command, even though I haven't specified a date format the xmp:gpsdatetime field now contains the UTC time 2 hours less than the datetimeoriginal, but it also shows an offset of +02:00 when it should not: GPS Date Time: 2007:08:02 16:33:44+02:00

I don't think the GPSDateTime should allow a UTC offset.

If on the other hand I attempt to force the format with -d, I have to be very specific with the format I provide.  If I use -d %Y%m%dT%H%M%S the gpstimestamp throws a fit and becomes a nonsensical value of "20073524:24:00".  -d "%Y:%m:%d %H:%M:%S" appears to work however.

I can live with forcing the format as in the second case, but just thought that it looks like a bug and you might want to know.  If the XMP:GPSDateTime field ignored any UTC offset, I could do what I needed in a single command rather than two as I currently have to.

Eamon

Archive

[Originally posted by exiftool on 2007-12-13 13:25:34-08]

I'm not sure I understand exactly what is going on.

First, I will assum you mean

Code:
"-DateTimeOriginal>gpstimestamp"

instead of

Code:
"-DateTimeOriginal-02>gpstimestamp"

But I don't know why you would want to set the value of GPSDateTime from
a date/time value which has a timezone.  The GPSDateTime should be in UTC,
but you appear to want to set it to a local time value.

Also, I don't understand how the gpsdatetime field could contain a value
which is different than what you write.  Make sure you are looking at the
correct tag.  There is also a composite GPSDateTime tag.  Use -a -G1
when you extract the information.

Your best bet is probably to create a couple of user-defined tags to do
exactly what you want.  In a user-defined tag, you could strip off timezone
information or convert to UTC or do whatever you want.

- Phil

Archive

[Originally posted by eam on 2007-12-13 14:31:24-08]

Ok, found my problem, it was to do with my user defined functions changing the source of the value it operated on after setting xmp values.  Basically, I have created a number of userdefined functions to help me that are called
DateTimeOriginal-01
DateTimeOriginal-02
DateTimeOriginal-03
etc.

These I simply use in order to generate the UTC time from the datetimeoriginal depending on the timezone and set the gpsdatestamp and gpstimestamp in one go.  Basically what is suggested in this thread but instead of a single "ShiftedDateTime" I have create one fore each timezone offset in my config.  These userdefined functions do not contain a timezone offset, well at least I never intended them to.  The are defined like this:

Code:
      'DateTimeOriginal-02' => {
            Require => {
                0 => 'DateTimeOriginal',
            },
            ValueConv => q{
                require 'Image/ExifTool/Shift.pl';
                Image::ExifTool::ShiftTime($val[0], '2', -1);
                return $val[0];
            },
            PrintConv => '$self->ConvertDateTime($val)',
        },

Turns out that once I have executed
Code:
exiftool "-all>xmp:all" -d "%Y:%m:%d %H:%M:%S+0200" test.jpg
my user defined function now starts to pull it's required field from the XMP:DateTimeOriginal which now has the timezone offset appended.

Problem now is how to I force my user defined functions to continue using the Exif:DateTimeOriginal after I have set the XMP version?  I tried changing the line
Code:
0 => 'DateTimeOriginal',
to
Code:
0 => 'EXIF:DateTimeOriginal',
but this just broke my user function.

Eamon

Archive

[Originally posted by exiftool on 2007-12-13 15:56:59-08]

Using "0 => 'EXIF:DateTimeOriginal'," is correct, and should work
as long as the tag is available.  How did it break things?

- Phil

Archive

[Originally posted by eam on 2007-12-13 16:30:19-08]

All ok now, it was a case sensitivity issue. Though I had written "EXIF:DateTimeOriginal" in my reply I actually had used "exif:DateTimeOriginal" in the config, I guess because exiftool isn't so picky about case sensitivity I didn't think about it in the config.  

I do find it slightly odd though that it reads the XMP:DateTimeOriginal value over the EXIF version when it will do the opposite when writing according to the help:
Code:
        If a group name is not specified for *TAG*, then the information is
         written to the preferred group, which is the first group in the
         following list where *TAG* is valid: 1) EXIF, 2) IPTC, 3) XMP, 4)
         MakerNotes.
Anyway, all working as expected now, thanks for your patience.

Eamon.