Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ build/
node_modules/
test/copy.jpg
*~
npm-debug.log
*.swp
.vagrant
Vagrantfile

*.o
*.lo
*.a
*.la
.vs
.vscode
yarn-error.log
yarn.lock
23 changes: 7 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
language: node_js
node_js:
- "4"
- "5"
- "6"
- "7"
- "node"
- "iojs"
- "0.12"
- "0.10"
- "8"
- "9"
- "10"
- "11"
- "12"
- "13"
- "14"
sudo: false
addons:
apt:
Expand All @@ -18,11 +17,3 @@ addons:
- libexiv2-dev
before_install:
- export CXX=g++-4.8
- case ${TRAVIS_NODE_VERSION} in
iojs*)
echo "Not upgrading npm for iojs."
;;
*)
npm update -g [email protected]
;;
esac
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Exiv2
# Exiv2

Exiv2 is a native c++ extension for [io.js](https://iojs.org/en/index.html) and
[node.js](https://nodejs.org/) that provides support for reading and writing
Expand All @@ -11,7 +11,7 @@ a package manager you might need to install an additional "-dev" packages.

### Debian

apt-get install libexiv2 libexiv2-dev
apt-get install zlib1g-dev

### OS X

Expand All @@ -25,6 +25,20 @@ You'll also need to install pkg-config to help locate the library and headers.

brew install pkg-config exiv2

### Windows
Install pkg-config using [Chocolatey](https://chocolatey.org/):

choco install pkgconfiglite

Download latest `msvc64` exiv2 build from the [Exiv2 download page](http://www.exiv2.org/download.html) and extract to a folder of your choice.

Add a system variable named `PKG_CONFIG_PATH` and set it's value to `EXIV2ROOTDIR\lib\pkgconfig` replacing `EXIV2ROOTDIR` with the path where you extracted exiv2 from the step before (e.g. `D:\src\exiv2msvs\lib\pkgconfig`).

You'll also need [windows-build-tools](https://www.npmjs.com/package/windows-build-tools) to compile this package.

For Electron apps, you'll want to copy `exiv2.dll` to the root directory of your Electron Windows build. You can automated this using the [extraFiles option](https://www.electron.build/configuration/contents#extrafiles).


### Other systems

See the [Exiv2 download page](http://www.exiv2.org/download.html) for more
Expand Down
37 changes: 31 additions & 6 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
'variables': {
'EXIV2_LIB': '<!(pkg-config --variable=libdir exiv2)'
},
'targets': [
{
'target_name': 'exiv2',
Expand All @@ -10,16 +13,38 @@
"<!(node -e \"require('nan')\")"
],
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET': '10.7',
'MACOSX_DEPLOYMENT_TARGET': '10.12',
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'OTHER_CPLUSPLUSFLAGS': ['-stdlib=libc++','-fcxx-exceptions', '-frtti'],
'OTHER_CPLUSPLUSFLAGS': [
'-stdlib=libc++',
'-fcxx-exceptions',
'-frtti',
'-fexceptions'
],
},
'cflags_cc': [
'-fexceptions'
"cflags": [
"-Wdeprecated-declarations",
"-fexceptions",
"-frtti"
],
'libraries': [
'<!@(pkg-config --libs exiv2)'
'cflags_cc': [
'-fexceptions',
"-frtti",
"-Wdeprecated-declarations"
],
'conditions': [[
'OS=="win"',
{
'libraries': [
'<(EXIV2_LIB)/exiv2.lib'
],
},
{
'libraries': [
'<!@(pkg-config --libs exiv2)'
]
}
]]
}
]
}
61 changes: 42 additions & 19 deletions exiv2node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
#include <node.h>
#include <node_buffer.h>
#include <nan.h>
#include <unistd.h>
#ifdef _MSC_VER
# include <direct.h>
# include <process.h>
#else
# include <unistd.h>
# include <stdint.h>
#endif
#include <string>
#include <map>
#include <exception>
Expand Down Expand Up @@ -88,7 +94,8 @@ class GetTagsWorker : public Exiv2Worker {
Local<Object> hash = Nan::New<Object>();
// Copy the tags out.
for (tag_map_t::iterator i = tags.begin(); i != tags.end(); ++i) {
hash->Set(
Nan::Set(
hash,
Nan::New<String>(i->first.c_str()).ToLocalChecked(),
Nan::New<String>(i->second.c_str()).ToLocalChecked()
);
Expand All @@ -97,7 +104,7 @@ class GetTagsWorker : public Exiv2Worker {
}

// Pass the argv array object to our callback function.
callback->Call(2, argv);
Nan::Call(callback->GetFunction(), Nan::GetCurrentContext()->Global(), 2, argv);
};
};

Expand Down Expand Up @@ -173,7 +180,7 @@ class SetTagsWorker : public Exiv2Worker {
}

// Pass the argv array object to our callback function.
callback->Call(1, argv);
Nan::Call(callback->GetFunction(), Nan::GetCurrentContext()->Global(), 1, argv);
};
};

Expand All @@ -192,10 +199,10 @@ NAN_METHOD(SetImageTags) {
Local<Object> tags = Local<Object>::Cast(info[1]);
Local<Array> keys = Nan::GetOwnPropertyNames(tags).ToLocalChecked();
for (unsigned i = 0; i < keys->Length(); i++) {
Local<Value> key = keys->Get(i);
Local<Value> key = Nan::Get(keys, i).ToLocalChecked();
worker->tags.insert(std::pair<std::string, std::string> (
*Nan::Utf8String(key),
*Nan::Utf8String(tags->Get(key))
*Nan::Utf8String(Nan::Get(tags, key).ToLocalChecked())
));
}

Expand Down Expand Up @@ -267,7 +274,7 @@ class DeleteTagsWorker : public Exiv2Worker {
}

// Pass the argv array object to our callback function.
callback->Call(1, argv);
Nan::Call(callback->GetFunction(), Nan::GetCurrentContext()->Global(), 1, argv);
};
};

Expand All @@ -285,7 +292,7 @@ NAN_METHOD(DeleteImageTags) {

Local<Array> keys = Local<Array>::Cast(info[1]);
for (unsigned i = 0; i < keys->Length(); i++) {
Local<v8::Value> key = keys->Get(i);
Local<v8::Value> key = Nan::Get(keys, i).ToLocalChecked();
worker->tags.push_back(*Nan::Utf8String(key));
}

Expand Down Expand Up @@ -337,18 +344,18 @@ class GetPreviewsWorker : public Exiv2Worker {
Local<Array> array = Nan::New<Array>(previews.size());
for (size_t i = 0; i < previews.size(); ++i) {
Local<Object> preview = Nan::New<Object>();
preview->Set(Nan::New<String>("mimeType").ToLocalChecked(), Nan::New<String>(previews[i].mimeType.c_str()).ToLocalChecked());
preview->Set(Nan::New<String>("height").ToLocalChecked(), Nan::New<Number>(previews[i].height));
preview->Set(Nan::New<String>("width").ToLocalChecked(), Nan::New<Number>(previews[i].width));
preview->Set(Nan::New<String>("data").ToLocalChecked(), Nan::CopyBuffer(previews[i].data, previews[i].size).ToLocalChecked());
Nan::Set(preview, Nan::New<String>("mimeType").ToLocalChecked(), Nan::New<String>(previews[i].mimeType.c_str()).ToLocalChecked());
Nan::Set(preview, Nan::New<String>("height").ToLocalChecked(), Nan::New<Number>(previews[i].height));
Nan::Set(preview, Nan::New<String>("width").ToLocalChecked(), Nan::New<Number>(previews[i].width));
Nan::Set(preview, Nan::New<String>("data").ToLocalChecked(), Nan::CopyBuffer(previews[i].data, previews[i].size).ToLocalChecked());

array->Set(i, preview);
Nan::Set(array, i, preview);
}
argv[1] = array;
}

// Pass the argv array object to our callback function.
callback->Call(2, argv);
Nan::Call(callback->GetFunction(), Nan::GetCurrentContext()->Global(), 2, argv);
};

protected:
Expand Down Expand Up @@ -397,10 +404,26 @@ NAN_METHOD(GetImagePreviews) {

// - - -

void InitAll(Handle<Object> target) {
target->Set(Nan::New<String>("getImageTags").ToLocalChecked(), Nan::New<FunctionTemplate>(GetImageTags)->GetFunction());
target->Set(Nan::New<String>("setImageTags").ToLocalChecked(), Nan::New<FunctionTemplate>(SetImageTags)->GetFunction());
target->Set(Nan::New<String>("deleteImageTags").ToLocalChecked(), Nan::New<FunctionTemplate>(DeleteImageTags)->GetFunction());
target->Set(Nan::New<String>("getImagePreviews").ToLocalChecked(), Nan::New<FunctionTemplate>(GetImagePreviews)->GetFunction());
void InitAll(Local<Object> target) {
Nan::Set(
target,
Nan::New<String>("getImageTags").ToLocalChecked(),
Nan::GetFunction(Nan::New<FunctionTemplate>(GetImageTags)).ToLocalChecked()
);
Nan::Set(
target,
Nan::New<String>("setImageTags").ToLocalChecked(),
Nan::GetFunction(Nan::New<FunctionTemplate>(SetImageTags)).ToLocalChecked()
);
Nan::Set(
target,
Nan::New<String>("deleteImageTags").ToLocalChecked(),
Nan::GetFunction(Nan::New<FunctionTemplate>(DeleteImageTags)).ToLocalChecked()
);
Nan::Set(
target,
Nan::New<String>("getImagePreviews").ToLocalChecked(),
Nan::GetFunction(Nan::New<FunctionTemplate>(GetImagePreviews)).ToLocalChecked()
);
}
NODE_MODULE(exiv2, InitAll)
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
"url": "git://github.com/dberesford/exiv2node.git"
},
"dependencies": {
"nan": "~2.2"
"nan": "~2.14.0"
},
"devDependencies": {
"should": "*",
"mocha": "*"
"mocha": "*",
"should": "*"
},
"optionalDependencies": {},
"engines": {
"node": "~0.8.0"
"node": ">=8.0.0"
},
"main": "exiv2",
"scripts": {
"preuninstall": "rm -rf build/*",
"test": "mocha",
"install": "node-gyp rebuild"
"clean": "node-gyp clean",
"build": "node-gyp configure build"
},
"gypfile": true,
"contributors": [
Expand Down