exif data sniffers,
I have a very simple usecase, I am trying to get the time a picture was taken, and also get the timezone as an offset from GMT. I do not care for the more convenient, yet harder to programmatically deal with, timezone abbreviation (EST, EDT).
To my dismay, exiftool is unable to display this information accurately (on a mac):
$ exiftool -d "%Y-%m-%dT%H:%M:%S%Z" -S -DateTimeOriginal IMG_0141.JPG
DateTimeOriginal: 2012-12-17T07:35:32EST
$ exiftool -d "%Y-%m-%dT%H:%M:%S%z" -S -DateTimeOriginal IMG_0141.JPG
DateTimeOriginal: 2012-12-17T07:35:32
I was expecting it to do something like:
DateTimeOriginal: 2012-12-17T07:35:32-0500
Am I missing something or is this a limitation?
tia,
rouble
Hi Rouble,
EXIF does not store time zone information, so the information you want to display does not exist in EXIF. %Z just gives the system time zone name.
Even for XMP date/times, which do store the time zone, %Z still gives the system time zone.
- Phil
Edit: I have just added a feature to exiftool so %z (lower-case) gives the time zone in the format you want, but this still requires that the time zone exists in the metadata, so won't work for EXIF tags, but may be useful for XMP metadata. This will appear in ExifTool 9.46.
Quote from: Phil Harvey on January 08, 2014, 07:31:21 AM
Edit: I have just added a feature to exiftool so %z (lower-case) gives the time zone in the format you want, but this still requires that the time zone exists in the metadata, so won't work for EXIF tags, but may be useful for XMP metadata. This will appear in ExifTool 9.46.
Hi Phil, if exiftool is using timezones, shouldn't, for instance, "%s" use it as well so that the xmp:datetimeoriginal uses its own whilst the exif version uses none at all as it does at the moment?
alan@egremont:Venice_04$ exiftool -d "%s" -a -G -datetimeoriginal ahc_5335.jpg
[EXIF] Date/Time Original : 1376063921
[XMP] Date/Time Original : 1376063921
alan@egremont:Venice_04$ exiftool -a -G -datetimeoriginal ahc_5335.jpg
[EXIF] Date/Time Original : 2013:08:09 11:58:41
[XMP] Date/Time Original : 2013:08:09 11:58:41+02:00
alan@egremont:Venice_04$ date "+%z"
-0400
rouble, is your camera actually storing the timezone? Most cameras I've had don't. My Nikon D7000 does but it stores it in the maker notes
exiftool -G -timezone -daylightsavings ahc_5335.jpg
[MakerNotes] Timezone : +01:00
[MakerNotes] Daylight Savings : Yes
Hi Alan,
Quote from: Alan Clifford on January 08, 2014, 04:41:35 PM
Hi Phil, if exiftool is using timezones, shouldn't, for instance, "%s" use it as well so that the xmp:datetimeoriginal uses its own whilst the exif version uses none at all as it does at the moment?
True. In theory it should. Unfortunately strftime() doesn't accept a timezone. After doing a bit of reading however, it may be possible to play with the TZ environment variable and use tzset() to set the time zone for the library. I'll look into this, but it sounds a bit dangerous to me.
- Phil
Quote from: Phil Harvey on January 08, 2014, 07:51:32 PM
quote]
True. In theory it should. Unfortunately strftime() doesn't accept a timezone.
Ah, that must be why I have a subroutine called "sub getxmpepoch {" (Oh dear, Perl is rather incomprehensible if you haven't looked at it for sometime but I think I understand what I wrote).
Well, the tzset() didn't prove to be very useful. I think the best thing to do is to parse the %s and %z format codes myself, before calling strftime().
- Phil