Support #990
Get tag type from key
0%
Description
In the addmodel sample there is the type knowledge given at compile time e.g. tag Exif.Image.PrimaryChromaticities is of tag type Exiv2::URationalValue
. Now assume that only the key name is given but the tag type is not known a priori. Is there any chance to retrieve the type info from the TagInfo
structure?
History
Updated by Robin Mills about 7 years ago
- Category set to design
- Status changed from New to Assigned
- Assignee set to Robin Mills
- Target version set to 0.25
Thomas
Can you help me to understand your expectation here. Are you requesting an option for Exiv2(.exe) to list all known tags and their data types? Currently, exiv2(.exe) reports data type and value. However it only lists tag, type and value when used in an image.
Or do you want something changed in addmoddel.cpp to report data type?
Robin
Updated by Thomas Beutlich about 7 years ago
Robin,
what I would need is the tag type of any tag (not yet necessary in the image) at run-time. In the addmodel sample there is redundant knowledge that tag Exif.Image.PrimaryChromaticities is of tag type Exiv2::URationalValue
. But say a user wants to add any tag at rum-time how do I find out its tag type? Basically I then need to write a switch/case on the tag type to consider all different types. Is this possible?
Regards,
Thomas
Updated by Andreas Huggel about 7 years ago
Thomas, I think you're looking for ExifKey::defaultTypeId(). For your example (user wants to add tag at run-time but doesn't know its type) you don't need to use that though:
exifData["Exif.Image.PrimaryChromaticities"] = "1"
creates an Exifdatum without a value and the assignment operator calls Exifdatum::setValue(), which creates a value of the default type for the Exifdatum.
Andreas
Updated by Thomas Beutlich about 7 years ago
Indeed, that is what I was looking for. Thank you!
Exiv2::ExifKey key = Exiv2::ExifKey("Exif.Image.PrimaryChromaticities"); Exiv2::TypeId typeId = key.defaultTypeId();
Ticket can be closed.
Updated by Robin Mills about 7 years ago
- Status changed from Assigned to Resolved
- Assignee changed from Robin Mills to Andreas Huggel
I'm going to mark this as "Resolved". It'll be Closed during review as part of the v0.25 release process.
I've also assigned this to Andreas as he's the guy who's provided the solution. Thanks, Andreas.