diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2011-08-22 08:31:19 +0200 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2011-08-22 08:31:19 +0200 |
commit | 34f55f38b2bbb18843b53c6804f4410d9a3f1dc1 (patch) | |
tree | 1a3438d7dd8cbc31139a67ec228027dc474bfdb6 /src/exiv2wrapper.cpp | |
parent | 39ce84eb5a85f32a2f2521a7ba7d3451a1244584 (diff) | |
parent | 0d90a8a6a7339543b01f8548d330e279a2067ea6 (diff) | |
download | pyexiv2-34f55f38b2bbb18843b53c6804f4410d9a3f1dc1.tar.gz |
Correctly extract the type of an EXIF tag when read from an image.
Diffstat (limited to 'src/exiv2wrapper.cpp')
-rw-r--r-- | src/exiv2wrapper.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp index ad37f57..332b78f 100644 --- a/src/exiv2wrapper.cpp +++ b/src/exiv2wrapper.cpp @@ -1,6 +1,6 @@ // ***************************************************************************** /* - * Copyright (C) 2006-2010 Olivier Tilloy <olivier@tilloy.net> + * Copyright (C) 2006-2011 Olivier Tilloy <olivier@tilloy.net> * * This file is part of the pyexiv2 distribution. * @@ -554,6 +554,13 @@ ExifTag::ExifTag(const std::string& key, #if EXIV2_TEST_VERSION(0,21,0) Exiv2::ExifKey exifKey(key); _type = Exiv2::TypeInfo::typeName(exifKey.defaultTypeId()); + // Where available, extract the type from the metadata, it is more reliable + // than static type information. The exception is for user comments, for + // which we’d rather keep the 'Comment' type instead of 'Undefined'. + if ((_data != 0) && (_type != "Comment")) + { + _type = _datum->typeName(); + } _name = exifKey.tagName(); _label = exifKey.tagLabel(); _description = exifKey.tagDesc(); @@ -566,6 +573,13 @@ ExifTag::ExifTag(const std::string& key, const uint16_t tag = _datum->tag(); const Exiv2::IfdId ifd = _datum->ifdId(); _type = Exiv2::TypeInfo::typeName(Exiv2::ExifTags::tagType(tag, ifd)); + // Where available, extract the type from the metadata, it is more reliable + // than static type information. The exception is for user comments, for + // which we’d rather keep the 'Comment' type instead of 'Undefined'. + if ((_data != 0) && (_type != "Comment")) + { + _type = _datum->typeName(); + } _name = Exiv2::ExifTags::tagName(tag, ifd); _label = Exiv2::ExifTags::tagLabel(tag, ifd); _description = Exiv2::ExifTags::tagDesc(tag, ifd); |