Browse files

Merge pull request #11 from rfrench/master

Add support for IPTC & XMP data in GetImageTags
  • Loading branch information...
2 parents 5cbc9a0 + 2269557 commit 4c63c9bdf2ae6a8886aca351a69956c9c532c334 @dberesford committed May 10, 2012
Showing with 26 additions and 7 deletions.
  1. +1 −1 AUTHORS
  2. +25 −6 exiv2node.cc
View
2 AUTHORS
@@ -1,4 +1,4 @@
# Ordered by first contribution date
-Ryan French
+Ryan French <frenchrya@gmail.com>
andrew morton <drewish@katherinehouse.com>
View
31 exiv2node.cc
@@ -87,15 +87,34 @@ static void AfterGetImageTags(uv_work_t* req) {
// Create a V8 object with all the image tags and their corresponding
// values.
Exiv2::ExifData &exifData = thread_data->image->exifData();
- if (exifData.empty() == false) {
+ Exiv2::IptcData &iptcData = thread_data->image->iptcData();
+ Exiv2::XmpData &xmpData = thread_data->image->xmpData();
+
+ argv[1] = Local<Value>::New(Null());
+ if (exifData.empty() == false || iptcData.empty() == false || xmpData.empty() == false) {
Local<Object> tags = Object::New();
- Exiv2::ExifData::const_iterator end = exifData.end();
- for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
- tags->Set(String::New(i->key().c_str()), String::New(i->value().toString().c_str()), ReadOnly);
+
+ if (exifData.empty() == false) {
+ Exiv2::ExifData::const_iterator end = exifData.end();
+ for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
+ tags->Set(String::New(i->key().c_str()), String::New(i->value().toString().c_str()), ReadOnly);
+ }
+ }
+
+ if (iptcData.empty() == false) {
+ Exiv2::IptcData::const_iterator end = iptcData.end();
+ for (Exiv2::IptcData::const_iterator i = iptcData.begin(); i != end; ++i) {
+ tags->Set(String::New(i->key().c_str()), String::New(i->value().toString().c_str()), ReadOnly);
+ }
+ }
+
+ if (xmpData.empty() == false) {
+ Exiv2::XmpData::const_iterator end = xmpData.end();
+ for (Exiv2::XmpData::const_iterator i = xmpData.begin(); i != end; ++i) {
+ tags->Set(String::New(i->key().c_str()), String::New(i->value().toString().c_str()), ReadOnly);
+ }
}
argv[1] = tags;
- } else {
- argv[1] = Local<Value>::New(Null());
}
}

0 comments on commit 4c63c9b

Please sign in to comment.