Permalink
Browse files

Merge pull request #15 from drewish/node-gyp

Add node-gyp support.
  • Loading branch information...
2 parents 1128ff5 + 1f40b98 commit 149dc5b3057b0d832ad1915215163d3ba93eee8a @drewish drewish committed Oct 3, 2012
Showing with 60 additions and 12 deletions.
  1. +31 −9 README.md
  2. +25 −0 binding.gyp
  3. +4 −3 exiv2node.cc
View
@@ -2,25 +2,47 @@
#Exiv2
-Exiv2 is a native c++ extension for [node.js](http://nodejs.org/) that provides support for reading & writing image metadata via [Exiv2 library](http://www.exiv2.org).
+Exiv2 is a native c++ extension for [node.js](http://nodejs.org/) that provides
+support for reading and writing image metadata via the [Exiv2 library](http://www.exiv2.org).
## Dependencies
-To build this addon you'll need the Exiv2 library and headers. On Debian/Ubuntu, `sudo apt-get install exiv2 libexiv2-dev`. See the [Exiv2 download page](http://www.exiv2.org/download.html) for more information.
+To build this addon you'll need the Exiv2 library and headers so if you're using
+a package manager you might need to install an additional "-dev" packages.
-The tests are written using [Mocha](https://github.com/visionmedia/mocha) and [Should](https://github.com/visionmedia/should.js).
+### Debian
-## Installation Instructions
+ apt-get install libexiv2 libexiv2-dev
+
+### OS X
+
+You'll also need to install pkg-config to help locate the library and headers.
+
+[MacPorts](http://macports.org/):
+
+ port install pkgconfig exiv2
+
+[Homebrew](http://github.com/mxcl/homebrew/):
-Install the library and headers using package manager appropriate to your system:
+ brew install pkg-config exiv2
- - Debian: `apt-get install libexiv2 libexiv2-dev`
- - OS X: `port install exiv2`
+### Other systems
-Install the module with npm:
+See the [Exiv2 download page](http://www.exiv2.org/download.html) for more
+information.
+
+## Installation Instructions
+
+Once the dependencies are in place, you can build and install the module using
+npm:
npm install exiv2
+You can verify that everything is installed and operating correctly by running
+the tests:
+
+ npm test
+
## Sample Usage
### Read tags:
@@ -54,7 +76,7 @@ Install the module with npm:
"Exif.Photo.UserComment" : "Some Comment..",
"Exif.Canon.OwnerName" : "My Camera"
};
- ex.setImageTags('./photo.jpg', , function(err){
+ ex.setImageTags('./photo.jpg', newTags, function(err){
if (err) {
console.log(err);
} else {
View
@@ -0,0 +1,25 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'exiv2',
+ 'sources': [
+ 'exiv2node.cc'
+ ],
+ 'xcode_settings': {
+ 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
+ },
+ 'cflags': [
+ '<!@(pkg-config --cflags exiv2)'
+ ],
+ 'cflags_cc': [
+ '-fexceptions'
+ ],
+ 'libraries': [
+ '<!@(pkg-config --libs exiv2)'
+ ],
+ 'ldflags': [
+ '<!@(pkg-config --libs exiv2)'
+ ]
+ }
+ ]
+}
View
@@ -5,6 +5,7 @@
#include <unistd.h>
#include <string>
#include <map>
+#include <exception>
#include <exiv2/image.hpp>
#include <exiv2/exif.hpp>
#include <exiv2/preview.hpp>
@@ -160,7 +161,7 @@ static void GetImageTagsWorker(uv_work_t* req) {
thread_data->tags->insert(std::pair<std::string, std::string> (i->key(), i->value().toString()));
}
}
- } catch (Exiv2::AnyError& e) {
+ } catch (std::exception& e) {
thread_data->exifException.append(e.what());
}
}
@@ -237,7 +238,7 @@ static void SetImageTagsWorker(uv_work_t *req) {
// Write the Exif data to the image file.
image->setExifData(exifData);
image->writeMetadata();
- } catch (Exiv2::AnyError& e) {
+ } catch (std::exception& e) {
thread_data->exifException.append(e.what());
}
}
@@ -307,7 +308,7 @@ static void GetImagePreviewsWorker(uv_work_t *req) {
thread_data->previews[i++] = new Preview(pos->mimeType_, pos->height_,
pos->width_, (char*) image.pData(), pos->size_);
}
- } catch (Exiv2::AnyError& e) {
+ } catch (std::exception& e) {
thread_data->exifException.append(e.what());
}
}

0 comments on commit 149dc5b

Please sign in to comment.