Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 5 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Commits on Apr 20, 2012
@drewish drewish Add package.json so we can publish to npm. d4862a3
@drewish drewish Use the waf API for loading pkg-config info.
Reading http://www.freehackers.org/~tnagy/testdoc/single.html#pkg_config made
it clear that we're doing things the hard way, lets simplify.
768ab17
@drewish drewish Update the readme now that we can use npm. 1be272f
@drewish drewish Move tags into map before passing to worker.
We should not be calling V8 functions from the worker threads. To avoid this
this copy the tags from the object into a std::map and then let the worker
copy those into the exiv tags.
6a4025e
Commits on Apr 21, 2012
@dberesford Merge pull request #3 from drewish/building
Get it building
8a4ccda
Showing with 53 additions and 26 deletions.
  1. +9 −4 README.md
  2. +21 −13 exiv2node.cc
  3. +22 −0 package.json
  4. +1 −9 wscript
View
13 README.md
@@ -7,11 +7,16 @@ Exiv2Node is a native c++ extension for node.js that provides asynchronous suppo
Needs Exiv2, see http://www.exiv2.org/download.html.
-## Build Instructions
+## Installation Instructions
- - Download source
- - node-waf configure && node-waf build
- - node-waf install
+Install the library and headers using package manager appropriate to your system:
+
+ - Debian: `apt-get install libexiv2 libexiv2-dev`
+ - OS X: `port install exiv2`
+
+Install the module with npm:
+
+ npm install exiv2
## Sample Usage
View
34 exiv2node.cc
@@ -3,6 +3,7 @@
#include <node_version.h>
#include <unistd.h>
#include <string>
+#include <map>
#include <exiv2/image.hpp>
#include <exiv2/exif.hpp>
@@ -14,7 +15,6 @@ using namespace v8;
class Exiv2Node: ObjectWrap {
public:
-
static Persistent<FunctionTemplate> s_ct;
static void Init(Handle<Object> target) {
HandleScope scope;
@@ -45,12 +45,13 @@ class Exiv2Node: ObjectWrap {
}
/* structure for passing our various objects around libeio */
+ typedef std::map<std::string, std::string> tag_map_t;
struct exiv2node_thread_data_t {
Exiv2Node *exiv2node;
Exiv2::Image::AutoPtr image;
Persistent<Function> cb;
std::string fileName;
- Persistent<Object> tags;
+ tag_map_t *tags;
std::string exifException;
};
@@ -159,8 +160,17 @@ class Exiv2Node: ObjectWrap {
thread_data->exiv2node = exiv2node;
thread_data->cb = Persistent<Function>::New(cb);
thread_data->fileName = std::string(*String::AsciiValue(fileName));
- thread_data->tags = Persistent<Object>::New(tags);
thread_data->exifException = std::string();
+ thread_data->tags = new tag_map_t();
+
+ Local<Array> keys = tags->GetPropertyNames();
+ for (unsigned i = 0; i < keys->Length(); i++) {
+ Handle<v8::Value> key = keys->Get(i);
+ thread_data->tags->insert(std::pair<std::string, std::string> (
+ *String::AsciiValue(key),
+ *String::AsciiValue(tags->Get(key)))
+ );
+ }
exiv2node->Ref();
#if NODE_VERSION_AT_LEAST(0, 5, 4)
@@ -182,11 +192,9 @@ class Exiv2Node: ObjectWrap {
thread_data->image->readMetadata();
Exiv2::ExifData &exifData = thread_data->image->exifData();
- Local<Array> keys = thread_data->tags->GetPropertyNames();
- for (unsigned i = 0; i < keys->Length(); i++) {
- Handle<v8::Value> key = keys->Get(i);
- Exiv2::Exifdatum& tag = exifData[*String::AsciiValue(key)];
- tag.setValue(*String::AsciiValue(thread_data->tags->Get(key)));
+ // Assign the tags.
+ for (tag_map_t::iterator i = thread_data->tags->begin(); i != thread_data->tags->end(); ++i) {
+ exifData[i->first].setValue(i->second);
}
/* Write the Exif data to the image file */
@@ -222,6 +230,7 @@ class Exiv2Node: ObjectWrap {
}
thread_data->cb.Dispose();
+ delete thread_data->tags;
// Assuming std::auto_ptr does its job here and Exiv2::Image::AutoPtr is destroyed when it goes out of scope here..
delete thread_data;
@@ -233,9 +242,8 @@ class Exiv2Node: ObjectWrap {
Persistent<FunctionTemplate> Exiv2Node::s_ct;
extern "C" {
-static void init(Handle<Object> target) {
- Exiv2Node::Init(target);
-}
-NODE_MODULE(exiv2node, init)
-;
+ static void init(Handle<Object> target) {
+ Exiv2Node::Init(target);
+ }
+ NODE_MODULE(exiv2node, init);
}
View
22 package.json
@@ -0,0 +1,22 @@
+{
+ "author": "Damian Beresford <dberesford@gmail.com> (http://www.damianberesford.com/)",
+ "name": "exiv2",
+ "description": "A native c++ extension for node.js that provides asynchronous support for reading & writing image metadata via Exiv2 .",
+ "version": "0.0.1",
+ "homepage": "https://github.com/dberesford/exiv2node",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/dberesford/exiv2node.git"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "main": "exiv2node.node",
+ "scripts": {
+ "install" : "node-waf install",
+ "preuninstall": "rm -rf build/*"
+ }
+}
View
10 wscript
@@ -8,15 +8,7 @@ def set_options(opt):
def configure(conf):
conf.check_tool("compiler_cxx")
conf.check_tool("node_addon")
- conf.check_cfg(package='exiv2')
-
- pkgconfig = conf.find_program('pkg-config', var='PKGCONFIG', mandatory=True)
- #exiv2_libdir = popen("%s --libdir exiv2" % pkgconfig).readline().strip()
- conf.env.append_value("LIBPATH_EXIV2", "/usr/local/lib")
- conf.env.append_value("LIB_EXIV2", "exiv2")
-
- exiv2_incdir = popen("%s --cflags exiv2" % pkgconfig).readline().strip()
- conf.env.append_value("CPPPATH_EXIV2", exiv2_incdir)
+ conf.check_cfg(package='exiv2', args='--cflags --libs')
def build(bld):
obj = bld.new_task_gen("cxx", "shlib", "node_addon")

No commit comments for this range

Something went wrong with that request. Please try again.