Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

node-gyp support #15

Merged
merged 3 commits into from

1 participant

@drewish
Collaborator

I got node-gyp working on OS X but it needs testing on other platforms. I also did some updates on the docs.

drewish added some commits
@drewish drewish Allow builds via node-gyp.
node-gyp disables C++ exeptions, presumably for performance reasons, so we
have to enable those ourselves. I'm unsure why but catching Exiv2::AnyError
is no longer sufficient to handle invalid file paths. Switching to its
parent class std::exception resolved the problem and seems reasonable since
we're not using AnyError's functionality.
e552773
@drewish drewish Updates to the README.
Split out the installation instructions to make the platform specifics clearer.
Fixed a bug in the sample code.
992f1cb
@drewish drewish Make sure gcc enabled exceptions. 1f40b98
@drewish drewish merged commit 149dc5b into dberesford:master
@drewish drewish deleted the drewish:node-gyp branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 14, 2012
  1. @drewish

    Allow builds via node-gyp.

    drewish authored
    node-gyp disables C++ exeptions, presumably for performance reasons, so we
    have to enable those ourselves. I'm unsure why but catching Exiv2::AnyError
    is no longer sufficient to handle invalid file paths. Switching to its
    parent class std::exception resolved the problem and seems reasonable since
    we're not using AnyError's functionality.
  2. @drewish

    Updates to the README.

    drewish authored
    Split out the installation instructions to make the platform specifics clearer.
    Fixed a bug in the sample code.
Commits on Oct 3, 2012
  1. @drewish
This page is out of date. Refresh to see the latest.
Showing with 60 additions and 12 deletions.
  1. +31 −9 README.md
  2. +25 −0 binding.gyp
  3. +4 −3 exiv2node.cc
View
40 README.md
@@ -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
25 binding.gyp
@@ -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
7 exiv2node.cc
@@ -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());
}
}
Something went wrong with that request. Please try again.