Project

General

Profile

get timezone part of DateTimeOriginal from an xmp sidecar file

Added by Linus Lee over 10 years ago

It seems the "DateTimeOriginal" value is automatically converted to localtime, and there is no way to get the "timezone" part of the original "DateTimeOriginal". For example, the following line in the xmp file is converted into "2010:08:14 21:02:01" (because the system's timezone is -05:00).

<exif:DateTimeOriginal>2010-08-14T19:02:01-07:00</exif:DateTimeOriginal>

I think the conversion is performed inside of Image::readMetadata(); this function calls copyXmpToExif() and finally reaches cnvXmpDate(). It seems SXMPUtils::ConvertToDate() invoked by cnvXmpDate() correctly extracts all the timezone information but this information is just discarded.

Could somebody please let me know how to access timezone? If there is no way without code change, I'd appreciate if somebody suggest an easy way.

Thanks!


Replies (2)

RE: get timezone part of DateTimeOriginal from an xmp sidecar file - Added by Andreas Huggel over 10 years ago

Linus Lee wrote:

It seems the "DateTimeOriginal" value is automatically converted to localtime, and there is no way to get the "timezone" part of the original "DateTimeOriginal".

During what operation?

Could somebody please let me know how to access timezone? If there is no way without code change, I'd appreciate if somebody suggest an easy way.

The XMP property Xmp.exif.DateTimeOriginal may have a timezone component and exiv2 shouldn't discard it. So you can always take it from there. However, the Exif tag Exif.Photo.DateTimeOriginal doesn't have a timezone part as the Exif specification doesn't cater for that.

When Exiv2 converts Xmp.exif.DateTimeOriginal to Exif.Photo.DateTimeOriginal it converts the timestamp to localtime and the timezone part is lost as there is no place to store it in Exif (well, except for Nikon AFAIK, which has a proprietary timezone field in their makernote but Exiv2 doesn't populate that).

Andreas

RE: get timezone part of DateTimeOriginal from an xmp sidecar file - Added by Linus Lee over 10 years ago

Andreas Huggel wrote:

During what operation?

At that time, I first called readMetadata(), and then iterated every single datum using iterator (exifData.begin(), and end()).

The XMP property Xmp.exif.DateTimeOriginal may have a timezone component and exiv2 shouldn't discard it. So you can always take it from there. However, the Exif tag Exif.Photo.DateTimeOriginal doesn't have a timezone part as the Exif specification doesn't cater for that.

When Exiv2 converts Xmp.exif.DateTimeOriginal to Exif.Photo.DateTimeOriginal it converts the timestamp to localtime and the timezone part is lost as there is no place to store it in Exif (well, except for Nikon AFAIK, which has a proprietary timezone field in their makernote but Exiv2 doesn't populate that).

Thank you for that information. I should have been more careful. Now, I can extract the timezone from "Xmp.exif.DateTimeOriginal".

I got a question. My code does the following:

Exiv2::XmpData &xmpData = image->xmpData();
Exiv2::XmpData::const_iterator end = xmpData.end();
for (Exiv2::XmpData::const_iterator i = xmpData.begin(); i != end; ++i) {
// the following raises an exception
i->copy(buffer, Exiv2::bigEndian);
}

I could see from xmp.hpp that copy has not been implemented. I was wondering if there is some rationale behind not implementing Xmpdatum::copy(). If there isn't, I was wondering if the following is fine:

i->value().copy(buffer, Exiv2::bigEndian);

Thanks!

    (1-2/2)