mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Bump node-addon-api for Buffer::NewOrCopy
This commit is contained in:
parent
90abd927c9
commit
e98993a6e2
@ -134,7 +134,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"color": "^4.2.3",
|
"color": "^4.2.3",
|
||||||
"detect-libc": "^2.0.1",
|
"detect-libc": "^2.0.1",
|
||||||
"node-addon-api": "^6.0.0",
|
"node-addon-api": "^6.1.0",
|
||||||
"prebuild-install": "^7.1.1",
|
"prebuild-install": "^7.1.1",
|
||||||
"semver": "^7.5.0",
|
"semver": "^7.5.0",
|
||||||
"simple-get": "^4.0.1",
|
"simple-get": "^4.0.1",
|
||||||
|
@ -65,16 +65,6 @@ namespace sharp {
|
|||||||
}
|
}
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
Napi::Buffer<char> NewOrCopyBuffer(Napi::Env env, char* data, size_t len) {
|
|
||||||
try {
|
|
||||||
return Napi::Buffer<char>::New(env, data, len, FreeCallback);
|
|
||||||
} catch (Napi::Error const &err) {
|
|
||||||
static_cast<void>(err);
|
|
||||||
}
|
|
||||||
Napi::Buffer<char> buf = Napi::Buffer<char>::Copy(env, data, len);
|
|
||||||
FreeCallback(nullptr, data);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create an InputDescriptor instance from a Napi::Object describing an input image
|
// Create an InputDescriptor instance from a Napi::Object describing an input image
|
||||||
InputDescriptor* CreateInputDescriptor(Napi::Object input) {
|
InputDescriptor* CreateInputDescriptor(Napi::Object input) {
|
||||||
|
@ -126,7 +126,6 @@ namespace sharp {
|
|||||||
return static_cast<T>(
|
return static_cast<T>(
|
||||||
vips_enum_from_nick(nullptr, type, AttrAsStr(obj, attr).data()));
|
vips_enum_from_nick(nullptr, type, AttrAsStr(obj, attr).data()));
|
||||||
}
|
}
|
||||||
Napi::Buffer<char> NewOrCopyBuffer(Napi::Env env, char* data, size_t len);
|
|
||||||
|
|
||||||
// Create an InputDescriptor instance from a Napi::Object describing an input image
|
// Create an InputDescriptor instance from a Napi::Object describing an input image
|
||||||
InputDescriptor* CreateInputDescriptor(Napi::Object input);
|
InputDescriptor* CreateInputDescriptor(Napi::Object input);
|
||||||
|
@ -230,20 +230,21 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|||||||
info.Set("orientation", baton->orientation);
|
info.Set("orientation", baton->orientation);
|
||||||
}
|
}
|
||||||
if (baton->exifLength > 0) {
|
if (baton->exifLength > 0) {
|
||||||
info.Set("exif", sharp::NewOrCopyBuffer(env, baton->exif, baton->exifLength));
|
info.Set("exif", Napi::Buffer<char>::NewOrCopy(env, baton->exif, baton->exifLength, sharp::FreeCallback));
|
||||||
}
|
}
|
||||||
if (baton->iccLength > 0) {
|
if (baton->iccLength > 0) {
|
||||||
info.Set("icc", sharp::NewOrCopyBuffer(env, baton->icc, baton->iccLength));
|
info.Set("icc", Napi::Buffer<char>::NewOrCopy(env, baton->icc, baton->iccLength, sharp::FreeCallback));
|
||||||
}
|
}
|
||||||
if (baton->iptcLength > 0) {
|
if (baton->iptcLength > 0) {
|
||||||
info.Set("iptc", sharp::NewOrCopyBuffer(env, baton->iptc, baton->iptcLength));
|
info.Set("iptc", Napi::Buffer<char>::NewOrCopy(env, baton->iptc, baton->iptcLength, sharp::FreeCallback));
|
||||||
}
|
}
|
||||||
if (baton->xmpLength > 0) {
|
if (baton->xmpLength > 0) {
|
||||||
info.Set("xmp", sharp::NewOrCopyBuffer(env, baton->xmp, baton->xmpLength));
|
info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
|
||||||
}
|
}
|
||||||
if (baton->tifftagPhotoshopLength > 0) {
|
if (baton->tifftagPhotoshopLength > 0) {
|
||||||
info.Set("tifftagPhotoshop",
|
info.Set("tifftagPhotoshop",
|
||||||
sharp::NewOrCopyBuffer(env, baton->tifftagPhotoshop, baton->tifftagPhotoshopLength));
|
Napi::Buffer<char>::NewOrCopy(env, baton->tifftagPhotoshop,
|
||||||
|
baton->tifftagPhotoshopLength, sharp::FreeCallback));
|
||||||
}
|
}
|
||||||
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
||||||
} else {
|
} else {
|
||||||
|
@ -1233,8 +1233,8 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
// Add buffer size to info
|
// Add buffer size to info
|
||||||
info.Set("size", static_cast<uint32_t>(baton->bufferOutLength));
|
info.Set("size", static_cast<uint32_t>(baton->bufferOutLength));
|
||||||
// Pass ownership of output data to Buffer instance
|
// Pass ownership of output data to Buffer instance
|
||||||
Napi::Buffer<char> data = sharp::NewOrCopyBuffer(env, static_cast<char*>(baton->bufferOut),
|
Napi::Buffer<char> data = Napi::Buffer<char>::NewOrCopy(env, static_cast<char*>(baton->bufferOut),
|
||||||
baton->bufferOutLength);
|
baton->bufferOutLength, sharp::FreeCallback);
|
||||||
Callback().MakeCallback(Receiver().Value(), { env.Null(), data, info });
|
Callback().MakeCallback(Receiver().Value(), { env.Null(), data, info });
|
||||||
} else {
|
} else {
|
||||||
// Add file size to info
|
// Add file size to info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user