Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-gyp support #15

Merged
merged 3 commits into from Oct 3, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 31 additions & 9 deletions README.md
Expand Up @@ -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:
Expand Down Expand Up @@ -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 {
Expand Down
25 changes: 25 additions & 0 deletions 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)'
]
}
]
}
7 changes: 4 additions & 3 deletions exiv2node.cc
Expand Up @@ -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>
Expand Down Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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());
}
}
Expand Down