mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Improve thread/buffer shutdown using new vips_thread_shutdown method - closes #5
This commit is contained in:
parent
f7b8ce1287
commit
7e8af63129
@ -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": {
|
||||
|
@ -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<Object>::New(buffer->handle_);
|
||||
vips_free(baton->buffer_out);
|
||||
}
|
||||
|
||||
baton->callback->Call(Context::GetCurrent()->Global(), 2, argv);
|
||||
@ -210,9 +212,15 @@ Handle<Value> Resize(const Arguments& args) {
|
||||
return Undefined();
|
||||
}
|
||||
|
||||
static void at_exit(void* arg) {
|
||||
HandleScope scope;
|
||||
vips_shutdown();
|
||||
}
|
||||
|
||||
extern "C" void init(Handle<Object> target) {
|
||||
HandleScope scope;
|
||||
vips_init("");
|
||||
AtExit(at_exit);
|
||||
NODE_SET_METHOD(target, "resize", Resize);
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user