Properly clear vips error data
This commit is contained in:
parent
207d950a6c
commit
4ccaea7c91
33 changed files with 259 additions and 222 deletions
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Blur(const Napi::CallbackInfo &info) {
|
Napi::Value Blur(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -31,15 +32,15 @@ Napi::Value Blur(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Caption(const Napi::CallbackInfo &info) {
|
Napi::Value Caption(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
|
@ -20,7 +22,8 @@ Napi::Value Caption(const Napi::CallbackInfo &info) {
|
||||||
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
||||||
type == "gif" ? options->set("n", -1) : options)
|
type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha()) in = in.bandjoin(255);
|
if (!in.has_alpha())
|
||||||
|
in = in.bandjoin(255);
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int size = width / 10;
|
int size = width / 10;
|
||||||
|
@ -62,17 +65,18 @@ Napi::Value Caption(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
final.write_to_buffer(
|
final.write_to_buffer(
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
|
: 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::New(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::New(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -22,7 +23,8 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
||||||
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
||||||
type == "gif" ? options->set("n", -1) : options)
|
type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha()) in = in.bandjoin(255);
|
if (!in.has_alpha())
|
||||||
|
in = in.bandjoin(255);
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int size = width / 13;
|
int size = width / 13;
|
||||||
|
@ -66,17 +68,18 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
final.write_to_buffer(
|
final.write_to_buffer(
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
|
: 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ using namespace Magick;
|
||||||
|
|
||||||
Napi::Value Circle(const Napi::CallbackInfo &info) {
|
Napi::Value Circle(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -46,14 +47,14 @@ Napi::Value Circle(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
writeImages(blurred.begin(), blurred.end(), &blob);
|
writeImages(blurred.begin(), blurred.end(), &blob);
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)blob.data(),
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)blob.data(),
|
||||||
blob.length()));
|
blob.length()));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@ VImage sepia = VImage::new_matrixv(3, 3, 0.3588, 0.7044, 0.1368, 0.2990, 0.5870,
|
||||||
|
|
||||||
Napi::Value Colors(const Napi::CallbackInfo &info) {
|
Napi::Value Colors(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -36,15 +37,15 @@ Napi::Value Colors(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Crop(const Napi::CallbackInfo &info) {
|
Napi::Value Crop(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -48,17 +49,18 @@ Napi::Value Crop(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
final.write_to_buffer(
|
final.write_to_buffer(
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
|
: 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,14 +7,13 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Deepfry(const Napi::CallbackInfo &info) {
|
Napi::Value Deepfry(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
|
|
||||||
VOption *options = VImage::option()->set("access", "sequential");
|
VOption *options = VImage::option()->set("access", "sequential");
|
||||||
|
|
||||||
VImage in =
|
VImage in =
|
||||||
|
@ -65,14 +64,15 @@ Napi::Value Deepfry(const Napi::CallbackInfo &info) {
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)
|
type == "gif" ? VImage::option()->set("dither", 0)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Flag(const Napi::CallbackInfo &info) {
|
Napi::Value Flag(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -58,13 +59,15 @@ Napi::Value Flag(const Napi::CallbackInfo &info) {
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Flip(const Napi::CallbackInfo &info) {
|
Napi::Value Flip(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -46,15 +47,15 @@ Napi::Value Flip(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Freeze(const Napi::CallbackInfo &info) {
|
Napi::Value Freeze(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -18,8 +19,6 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
|
||||||
? obj.Get("frame").As<Napi::Number>().Int32Value()
|
? obj.Get("frame").As<Napi::Number>().Int32Value()
|
||||||
: -1;
|
: -1;
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
|
|
||||||
char *fileData = data.Data();
|
char *fileData = data.Data();
|
||||||
char *match = (char *)"\x21\xFF\x0BNETSCAPE2.0\x03\x01";
|
char *match = (char *)"\x21\xFF\x0BNETSCAPE2.0\x03\x01";
|
||||||
char *descriptor = (char *)"\x2C\x00\x00\x00\x00";
|
char *descriptor = (char *)"\x2C\x00\x00\x00\x00";
|
||||||
|
@ -69,8 +68,6 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
} else {
|
} else {
|
||||||
lastPos = (char *)memchr(fileData, '\x21', data.Length());
|
lastPos = (char *)memchr(fileData, '\x21', data.Length());
|
||||||
|
@ -93,10 +90,13 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -51,15 +52,15 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Globe(const Napi::CallbackInfo &info) {
|
Napi::Value Globe(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -77,13 +78,15 @@ Napi::Value Globe(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
final.write_to_buffer(".gif", &buf, &length);
|
final.write_to_buffer(".gif", &buf, &length);
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", "gif");
|
result.Set("type", "gif");
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Homebrew(const Napi::CallbackInfo &info) {
|
Napi::Value Homebrew(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -34,15 +35,15 @@ Napi::Value Homebrew(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
out.write_to_buffer(".png", &buf, &length);
|
out.write_to_buffer(".png", &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", "png");
|
result.Set("type", "png");
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Invert(const Napi::CallbackInfo &info) {
|
Napi::Value Invert(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -30,15 +31,15 @@ Napi::Value Invert(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -16,8 +17,6 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
||||||
: 0;
|
: 0;
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
|
|
||||||
if (type == "gif") {
|
if (type == "gif") {
|
||||||
VImage in =
|
VImage in =
|
||||||
VImage::new_from_buffer(
|
VImage::new_from_buffer(
|
||||||
|
@ -67,8 +66,6 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)
|
type == "gif" ? VImage::option()->set("dither", 0)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,16 +76,16 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
||||||
".jpg", &buf, &length,
|
".jpg", &buf, &length,
|
||||||
VImage::option()->set("Q", quality)->set("strip", true));
|
VImage::option()->set("Q", quality)->set("strip", true));
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", "jpg");
|
result.Set("type", "jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ using namespace Magick;
|
||||||
|
|
||||||
Napi::Value Magik(const Napi::CallbackInfo &info) {
|
Napi::Value Magik(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -48,14 +49,14 @@ Napi::Value Magik(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
writeImages(blurred.begin(), blurred.end(), &blob);
|
writeImages(blurred.begin(), blurred.end(), &blob);
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)blob.data(),
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)blob.data(),
|
||||||
blob.length()));
|
blob.length()));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Meme(const Napi::CallbackInfo &info) {
|
Napi::Value Meme(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -130,15 +131,15 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Mirror(const Napi::CallbackInfo &info) {
|
Napi::Value Mirror(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -69,15 +70,15 @@ Napi::Value Mirror(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -108,13 +109,15 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 1) : 0);
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Reddit(const Napi::CallbackInfo &info) {
|
Napi::Value Reddit(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
|
@ -61,15 +63,15 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Resize(const Napi::CallbackInfo &info) {
|
Napi::Value Resize(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -59,15 +60,15 @@ Napi::Value Resize(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Reverse(const Napi::CallbackInfo &info) {
|
Napi::Value Reverse(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -57,15 +58,15 @@ Napi::Value Reverse(const Napi::CallbackInfo &info) {
|
||||||
final.write_to_buffer(".gif", &buf, &length,
|
final.write_to_buffer(".gif", &buf, &length,
|
||||||
VImage::option()->set("dither", 0));
|
VImage::option()->set("dither", 0));
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", "gif");
|
result.Set("type", "gif");
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ using namespace Magick;
|
||||||
|
|
||||||
Napi::Value Scott(const Napi::CallbackInfo &info) {
|
Napi::Value Scott(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -59,14 +60,14 @@ Napi::Value Scott(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)blob.data(),
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)blob.data(),
|
||||||
blob.length()));
|
blob.length()));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Snapchat(const Napi::CallbackInfo &info) {
|
Napi::Value Snapchat(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -69,15 +70,15 @@ Napi::Value Snapchat(const Napi::CallbackInfo &info) {
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Sonic(const Napi::CallbackInfo &info) {
|
Napi::Value Sonic(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -33,15 +34,15 @@ Napi::Value Sonic(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
out.write_to_buffer(".png", &buf, &length);
|
out.write_to_buffer(".png", &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", "png");
|
result.Set("type", "png");
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -37,13 +37,12 @@ void vipsRemove(Napi::Env *env, Napi::Object *result, Napi::Buffer<char> data,
|
||||||
size_t length;
|
size_t length;
|
||||||
out.write_to_buffer(".gif", &buf, &length);
|
out.write_to_buffer(".gif", &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
result->Set("data", Napi::Buffer<char>::Copy(*env, (char *)buf, length));
|
result->Set("data", Napi::Buffer<char>::Copy(*env, (char *)buf, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
Napi::Value Speed(const Napi::CallbackInfo &info) {
|
Napi::Value Speed(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -54,8 +53,6 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
|
||||||
int speed =
|
int speed =
|
||||||
obj.Has("speed") ? obj.Get("speed").As<Napi::Number>().Int32Value() : 2;
|
obj.Has("speed") ? obj.Get("speed").As<Napi::Number>().Int32Value() : 2;
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
|
|
||||||
char *fileData = data.Data();
|
char *fileData = data.Data();
|
||||||
|
|
||||||
char *match = (char *)"\x00\x21\xF9\x04";
|
char *match = (char *)"\x00\x21\xF9\x04";
|
||||||
|
@ -106,10 +103,13 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
|
||||||
if (removeFrames) vipsRemove(&env, &result, data, speed);
|
if (removeFrames) vipsRemove(&env, &result, data, speed);
|
||||||
|
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ using namespace Magick;
|
||||||
|
|
||||||
Napi::Value Tile(const Napi::CallbackInfo &info) {
|
Napi::Value Tile(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -61,14 +62,14 @@ Napi::Value Tile(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)blob.data(),
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)blob.data(),
|
||||||
blob.length()));
|
blob.length()));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value ToGif(const Napi::CallbackInfo &info) {
|
Napi::Value ToGif(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -14,12 +15,9 @@ Napi::Value ToGif(const Napi::CallbackInfo &info) {
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
|
|
||||||
if (type == "gif") {
|
if (type == "gif") {
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", data);
|
result.Set("data", data);
|
||||||
result.Set("type", "gif");
|
result.Set("type", "gif");
|
||||||
return result;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
VOption *options = VImage::option()->set("access", "sequential");
|
VOption *options = VImage::option()->set("access", "sequential");
|
||||||
|
|
||||||
VImage in =
|
VImage in =
|
||||||
|
@ -29,15 +27,16 @@ Napi::Value ToGif(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
in.write_to_buffer(".gif", &buf, &length);
|
in.write_to_buffer(".gif", &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", "gif");
|
result.Set("type", "gif");
|
||||||
return result;
|
}
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -54,15 +55,15 @@ Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ using namespace Magick;
|
||||||
|
|
||||||
Napi::Value Wall(const Napi::CallbackInfo &info) {
|
Napi::Value Wall(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -54,14 +55,14 @@ Napi::Value Wall(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)blob.data(),
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)blob.data(),
|
||||||
blob.length()));
|
blob.length()));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Watermark(const Napi::CallbackInfo &info) {
|
Napi::Value Watermark(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -156,15 +157,15 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Whisper(const Napi::CallbackInfo &info) {
|
Napi::Value Whisper(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -83,15 +84,15 @@ Napi::Value Whisper(const Napi::CallbackInfo &info) {
|
||||||
("." + type).c_str(), &buf, &length,
|
("." + type).c_str(), &buf, &length,
|
||||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1) : 0);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using namespace vips;
|
||||||
|
|
||||||
Napi::Value Zamn(const Napi::CallbackInfo &info) {
|
Napi::Value Zamn(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
|
@ -47,15 +48,15 @@ Napi::Value Zamn(const Napi::CallbackInfo &info) {
|
||||||
size_t length;
|
size_t length;
|
||||||
final.write_to_buffer(("." + type).c_str(), &buf, &length);
|
final.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||||
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
Napi::Object result = Napi::Object::New(env);
|
|
||||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
return result;
|
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const &err) {
|
||||||
throw Napi::Error::New(env, err.what());
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Napi::Error::New(env, "Unknown error");
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vips_error_clear();
|
||||||
|
vips_thread_shutdown();
|
||||||
|
return result;
|
||||||
}
|
}
|
Loading…
Reference in a new issue