diff --git a/package.json b/package.json index 3b2d46d7..1a94e911 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sharp", - "version": "0.0.7", + "version": "0.0.8", "author": "Lovell Fuller", "description": "High performance module to resize JPEG and PNG images using the libvips image processing library", "scripts": { diff --git a/src/sharp.cc b/src/sharp.cc index 693ea97b..68ec36a7 100755 --- a/src/sharp.cc +++ b/src/sharp.cc @@ -160,6 +160,7 @@ void ResizeAsync(uv_work_t *work) { } else { (baton->err).append("Unsupported output file type"); } + vips_thread_shutdown(); } void ResizeAsyncAfter(uv_work_t *work, int status) { @@ -176,6 +177,7 @@ void ResizeAsyncAfter(uv_work_t *work, int status) { // Buffer Buffer *buffer = Buffer::New((const char*)(baton->buffer_out), baton->buffer_out_len); argv[1] = Local::New(buffer->handle_); + vips_free(baton->buffer_out); } baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); @@ -210,9 +212,15 @@ Handle Resize(const Arguments& args) { return Undefined(); } +static void at_exit(void* arg) { + HandleScope scope; + vips_shutdown(); +} + extern "C" void init(Handle target) { HandleScope scope; vips_init(""); + AtExit(at_exit); NODE_SET_METHOD(target, "resize", Resize); }; diff --git a/tests/perf.js b/tests/perf.js index f3c9e078..7a51d84e 100755 --- a/tests/perf.js +++ b/tests/perf.js @@ -12,7 +12,7 @@ var outputJpgLength = 47035; var inputPng = __dirname + "/50020484-00001.png"; // http://c.searspartsdirect.com/lis_png/PLDM/50020484-00001.png var outputPng = __dirname + "/output.png"; -var outputPngLength = 60379; +var outputPngLength = 60380; var width = 640; var height = 480;