Newby questions.
Added by Mikayel Egibyan over 6 years ago
Hi, I have two questions:
1. Where can I find a file/source with a list of all supported tags and domains?
e.g.
EXIF
"Exif.Image.Model"
"Exif.Image.MakerNote"
......
XMP
.....
IPTC
....
- Is it string output?
- Is there a difference if I am trying to get/set string, float or integer value, or exifData["Exif.Image.*Tag*"] will give me the result? Always as a string, or corresponding type?
-
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open("img");
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
cout << exifData["Exif.Image.Model"].to_string();
This gives a 0 output. What's wrong in my code?
p.s. img has Model tag!
Thanks,
Mikayel
Replies (3)
RE: Newby questions. - Added by Mikayel Egibyan over 6 years ago
The second question was not working because another bug I had. Please answer question 1.
RE: Newby questions. - Added by Robin Mills over 6 years ago
Mikayel
I didn't write Exiv2 and don't know a lot about how it is implemented. However I don't believe the code has any "built in" expectations about keys and values. It reports what it finds. The metadata enumerator 'i':
Exiv2::ExifData& exifData = image->exifData(); Exiv2::ExifData::const_iterator end = exifData.end(); for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) { ... }has methods such as key() and value() which reveal this information. There is a type() method to reveal the type of the value(). The exif2 spec states on page 14: http://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf
The following types are used in Exif: 1 = BYTE 2 = ASCII 3 = SHORT 4 = LONG 5 = RATIONAL 7 = UNDEFINED 9 = SLONG 10 = SRATIONALThe method typename() converts type() to an ascii string. So i->type() 2 => i->typename() "Ascii". You'll see this being used in the code in our discussion last week: http://dev.exiv2.org/boards/3/topics/1888
I think this is a good design because we don't need to modify our code-base to handle new key/values approved by the standards committee. Of course, it they decided to add a new type (e.g. URI or DATE), we'd have to change Exiv2 to respect that.
To answer your question "What's wrong with my code?", I ran this command on a photo I took recently:
514 rmills@rmillsmbp:~/Pictures/2015/WinterTrip/SanAntonio $ exiv2 -pt -g Model DSC_6039.jpg Exif.Image.Model Ascii 12 NIKON D5300 515 rmills@rmillsmbp:~/Pictures/2015/WinterTrip/SanAntonio $I don't think you need the to_string() method. I believe the following will be sufficient:
cout << exifData["Exif.Image.Model"];I encourage you to step the code in the beautiful Visual Studio debugger for additional enlightenment.
Robin
RE: Newby questions. - Added by Andreas Huggel over 6 years ago
Mikayel Egibyan wrote:
Hi, I have two questions:
1. Where can I find a file/source with a list of all supported tags and domains?
Tag reference tables are here: http://www.exiv2.org/metadata.html
If that's not what you're looking for, please clarify.
[...]
2. exifData["Exif.Image.Model"] this is supposed to give the resulting value of the model right?
- Is it string output?
exifData["Exif.Image.Model"] returns an Exifdatum&, not a string.
- Is there a difference if I am trying to get/set string, float or integer value, or exifData["Exif.Image.*Tag*"] will give me the result? Always as a string, or corresponding type?
To set a value, you can either provide it as a string and let Exiv2 parse it, or provide it in the correct format (as per the reference tables), which saves the parsing overhead. See the different assignment operators of class Exifdatum and examples.
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open("img");
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
cout << exifData["Exif.Image.Model"].to_string();This gives a 0 output. What's wrong in my code?
p.s. img has Model tag!
See above, exifData["Exif.Image.Model"] returns an Exifdatum&. Exifdatum is derived from class Metadatum and there is an output operator for Metadatum, so you don't need to try to convert it to a string first. Just write cout << exifData["Exif.Image.Model"];
Thanks,
Mikayel
Regards,
Andreas