Portablized more natives
This commit is contained in:
parent
a01e2ae77b
commit
e1a31d6ddc
25 changed files with 698 additions and 843 deletions
|
@ -1,24 +1,19 @@
|
|||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
char *Gamexplain(string type, char *BufferData, size_t BufferLength,
|
||||
ArgumentMap Arguments, size_t *DataSize) {
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
|
||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
VImage in =
|
||||
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||
type == "gif" ? options->set("n", -1) : options)
|
||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||
if (!in.has_alpha())
|
||||
|
@ -35,12 +30,11 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
|||
for (int i = 0; i < nPages; i++) {
|
||||
VImage img_frame =
|
||||
type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
|
||||
VImage resized = img_frame
|
||||
VImage resized =
|
||||
img_frame
|
||||
.resize(1181.0 / (double)width,
|
||||
VImage::option()->set(
|
||||
"vscale", 571.0 / (double)pageHeight))
|
||||
.embed(10, 92, 1200, 675,
|
||||
VImage::option()->set("extend", "white"));
|
||||
VImage::option()->set("vscale", 571.0 / (double)pageHeight))
|
||||
.embed(10, 92, 1200, 675, VImage::option()->set("extend", "white"));
|
||||
VImage composited = resized.composite2(tmpl, VIPS_BLEND_MODE_OVER);
|
||||
img.push_back(composited);
|
||||
}
|
||||
|
@ -48,21 +42,13 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
|||
final.set(VIPS_META_PAGE_HEIGHT, 675);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
final.write_to_buffer(
|
||||
("." + type).c_str(), &buf, &length,
|
||||
("." + type).c_str(), &buf, DataSize,
|
||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||
: 0);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", type);
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
|
||||
return (char *)buf;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Gamexplain(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Gamexplain(string type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,25 +1,20 @@
|
|||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Globe(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
char *Globe(string type, char *BufferData, size_t BufferLength,
|
||||
ArgumentMap Arguments, size_t *DataSize) {
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
|
||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||
|
||||
VOption *options = VImage::option();
|
||||
|
||||
VImage in =
|
||||
VImage::new_from_buffer(
|
||||
data.Data(), data.Length(), "",
|
||||
BufferData, BufferLength, "",
|
||||
type == "gif" ? options->set("n", -1)->set("access", "sequential")
|
||||
: options)
|
||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||
|
@ -76,18 +71,9 @@ Napi::Value Globe(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
final.write_to_buffer(".gif", &buf, &length);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", "gif");
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
final.write_to_buffer(".gif", &buf, DataSize);
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Globe(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Globe(string type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,28 +1,22 @@
|
|||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Homebrew(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
|
||||
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
|
||||
char *Homebrew(string *type, ArgumentMap Arguments, size_t *DataSize) {
|
||||
string caption = GetArgument<string>(Arguments, "caption");
|
||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||
|
||||
string assetPath = basePath + "assets/images/hbc.png";
|
||||
VImage bg = VImage::new_from_file(assetPath.c_str());
|
||||
|
||||
VImage text = VImage::text(
|
||||
".", VImage::option()->set(
|
||||
"fontfile", (basePath + "assets/fonts/hbc.ttf").c_str()));
|
||||
".", VImage::option()->set("fontfile",
|
||||
(basePath + "assets/fonts/hbc.ttf").c_str()));
|
||||
text = VImage::text(
|
||||
("<span letter_spacing=\"-5120\" color=\"white\">" + caption +
|
||||
"</span>")
|
||||
("<span letter_spacing=\"-5120\" color=\"white\">" + caption + "</span>")
|
||||
.c_str(),
|
||||
VImage::option()
|
||||
->set("rgba", true)
|
||||
|
@ -36,18 +30,11 @@ Napi::Value Homebrew(const Napi::CallbackInfo &info) {
|
|||
->set("y", 300 - (text.height() / 2) - 8));
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
out.write_to_buffer(".png", &buf, &length);
|
||||
out.write_to_buffer(".png", &buf, DataSize);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", "png");
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
*type = "png";
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Homebrew(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Homebrew(string *type, ArgumentMap Arguments, size_t *DataSize);
|
|
@ -63,27 +63,30 @@ std::map<std::string, char* (*)(string type, char* BufferData, size_t BufferLeng
|
|||
{"flag", &Flag},
|
||||
{"flip", &Flip},
|
||||
{"freeze", &Freeze},
|
||||
{"speed", &Speed},
|
||||
{"uncaption", &Uncaption},
|
||||
{"watermark", &Watermark}
|
||||
};
|
||||
|
||||
std::map<std::string, Napi::Value (*)(const Napi::CallbackInfo &info)> OldFunctionMap = {
|
||||
{"gamexplain", Gamexplain},
|
||||
{"globe", Globe},
|
||||
{"homebrew", Homebrew},
|
||||
{"invert", Invert},
|
||||
{"jpeg", Jpeg},
|
||||
{"magik", Magik},
|
||||
{"meme", Meme},
|
||||
{"mirror", Mirror},
|
||||
{"motivate", Motivate},
|
||||
{"reddit", Reddit},
|
||||
{"resize", Resize},
|
||||
{"reverse", Reverse},
|
||||
{"speed", &Speed},
|
||||
{"uncaption", &Uncaption},
|
||||
{"watermark", &Watermark}
|
||||
};
|
||||
|
||||
std::map<std::string, char* (*)(string *type, ArgumentMap Arguments, size_t* DataSize)> NoInputFunctionMap = {
|
||||
{"homebrew", Homebrew},
|
||||
{"sonic", Sonic}
|
||||
};
|
||||
|
||||
std::map<std::string, Napi::Value (*)(const Napi::CallbackInfo &info)> OldFunctionMap = {
|
||||
{"magik", Magik},
|
||||
{"scott", Scott},
|
||||
{"snapchat", Snapchat},
|
||||
{"sonic", Sonic},
|
||||
{"spin", Spin},
|
||||
{"swirl", Swirl},
|
||||
{"tile", Tile},
|
||||
|
@ -105,15 +108,14 @@ bool isNapiValueInt(Napi::Env& env, Napi::Value& num) {
|
|||
.Value();
|
||||
}
|
||||
|
||||
Napi::Value NewProcessImage(const Napi::CallbackInfo &info) {
|
||||
Napi::Value NewProcessImage(const Napi::CallbackInfo &info, bool input) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
try {
|
||||
string command = info[0].As<Napi::String>().Utf8Value();
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
string type = obj.Has("type") ? obj.Get("type").As<Napi::String>().Utf8Value() : NULL;
|
||||
|
||||
Napi::Array properties = obj.GetPropertyNames();
|
||||
|
||||
|
@ -145,7 +147,13 @@ Napi::Value NewProcessImage(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
|
||||
size_t length = 0;
|
||||
char* buf = FunctionMap.at(command)(type, data.Data(), data.Length(), Arguments, &length);
|
||||
char* buf;
|
||||
if (input) {
|
||||
Napi::Buffer<char> data = obj.Has("data") ? obj.Get("data").As<Napi::Buffer<char>>() : Napi::Buffer<char>::New(env, 0);
|
||||
buf = FunctionMap.at(command)(type, data.Data(), data.Length(), Arguments, &length);
|
||||
} else {
|
||||
buf = NoInputFunctionMap.at(command)(&type, Arguments, &length);
|
||||
}
|
||||
result.Set("data", Napi::Buffer<char>::New(env, buf, length, [](Napi::Env env, void* data) {
|
||||
free(data);
|
||||
}));
|
||||
|
@ -169,7 +177,9 @@ Napi::Value ProcessImage(const Napi::CallbackInfo &info) { // janky solution for
|
|||
string command = info[0].As<Napi::String>().Utf8Value();
|
||||
|
||||
if (MAP_HAS(FunctionMap, command)) {
|
||||
return NewProcessImage(info);
|
||||
return NewProcessImage(info, true);
|
||||
} else if (MAP_HAS(NoInputFunctionMap, command)) {
|
||||
return NewProcessImage(info, false);
|
||||
} else if (MAP_HAS(OldFunctionMap, command)) {
|
||||
return OldProcessImage(command, info);
|
||||
} else {
|
||||
|
@ -193,6 +203,11 @@ Napi::Object Init(Napi::Env env, Napi::Object exports){
|
|||
arr[i] = Napi::String::New(env, imap.first);
|
||||
i++;
|
||||
}
|
||||
for (auto const& imap: NoInputFunctionMap) {
|
||||
Napi::HandleScope scope(env);
|
||||
arr[i] = Napi::String::New(env, imap.first);
|
||||
i++;
|
||||
}
|
||||
for(auto const& imap: OldFunctionMap) {
|
||||
Napi::HandleScope scope(env);
|
||||
arr[i] = Napi::String::New(env, imap.first);
|
||||
|
|
|
@ -1,26 +1,21 @@
|
|||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Invert(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
char *Invert(string type, char *BufferData, size_t BufferLength,
|
||||
ArgumentMap Arguments, size_t *DataSize) {
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
VImage in =
|
||||
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||
type == "gif" ? options->set("n", -1) : options)
|
||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||
if (!in.has_alpha())
|
||||
in = in.bandjoin(255);
|
||||
|
||||
VImage noAlpha =
|
||||
in.extract_band(0, VImage::option()->set("n", in.bands() - 1));
|
||||
|
@ -28,18 +23,9 @@ Napi::Value Invert(const Napi::CallbackInfo &info) {
|
|||
VImage out = inverted.bandjoin(in.extract_band(3));
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", type);
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, DataSize);
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Invert(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Invert(string type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,26 +1,19 @@
|
|||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
char *Jpeg(string type, char *BufferData, size_t BufferLength,
|
||||
ArgumentMap Arguments, size_t *DataSize) {
|
||||
int quality = GetArgumentWithFallback<int>(Arguments, "quality", 0);
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
int quality = obj.Has("quality")
|
||||
? obj.Get("quality").As<Napi::Number>().Int32Value()
|
||||
: 0;
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
void *buf;
|
||||
|
||||
if (type == "gif") {
|
||||
VImage in =
|
||||
VImage::new_from_buffer(
|
||||
data.Data(), data.Length(), "",
|
||||
VImage in = VImage::new_from_buffer(
|
||||
BufferData, BufferLength, "",
|
||||
VImage::option()->set("access", "sequential")->set("n", -1))
|
||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||
if (!in.has_alpha())
|
||||
|
@ -60,32 +53,18 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
|||
final.set("delay", in.get_array_int("delay"));
|
||||
}
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
final.write_to_buffer(("." + type).c_str(), &buf, &length,
|
||||
final.write_to_buffer(("." + type).c_str(), &buf, DataSize,
|
||||
type == "gif" ? VImage::option()->set("dither", 0)
|
||||
: 0);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", type);
|
||||
} else {
|
||||
VImage in = VImage::new_from_buffer(data.Data(), data.Length(), "");
|
||||
void *buf;
|
||||
size_t length;
|
||||
in.write_to_buffer(
|
||||
".jpg", &buf, &length,
|
||||
VImage in = VImage::new_from_buffer(BufferData, BufferLength, "");
|
||||
in.write_to_buffer(".jpg", &buf, DataSize,
|
||||
VImage::option()->set("Q", quality)->set("strip", true));
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", "jpg");
|
||||
}
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
type = "jpg";
|
||||
}
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Jpeg(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Jpeg(string type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,28 +1,21 @@
|
|||
#include "common.h"
|
||||
#include <napi.h>
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Meme(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string top = obj.Get("top").As<Napi::String>().Utf8Value();
|
||||
string bottom = obj.Get("bottom").As<Napi::String>().Utf8Value();
|
||||
string font = obj.Get("font").As<Napi::String>().Utf8Value();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
|
||||
char *Meme(string type, char *BufferData, size_t BufferLength,
|
||||
ArgumentMap Arguments, size_t *DataSize) {
|
||||
string top = GetArgument<string>(Arguments, "top");
|
||||
string bottom = GetArgument<string>(Arguments, "bottom");
|
||||
string font = GetArgument<string>(Arguments, "font");
|
||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
VImage in =
|
||||
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||
type == "gif" ? options->set("n", -1) : options)
|
||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||
if (!in.has_alpha())
|
||||
|
@ -36,9 +29,9 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
int rad = 1;
|
||||
vector<double> zeroVec = {0, 0, 0, 0};
|
||||
|
||||
string font_string = (font == "roboto" ? "Roboto Condensed" : font) + ", Twemoji Color Font " +
|
||||
(font != "impact" ? "bold" : "normal") +
|
||||
" " + to_string(size);
|
||||
string font_string =
|
||||
(font == "roboto" ? "Roboto Condensed" : font) + ", Twemoji Color Font " +
|
||||
(font != "impact" ? "bold" : "normal") + " " + to_string(size);
|
||||
|
||||
VImage mask = VImage::black(rad * 2 + 1, rad * 2 + 1) + 128;
|
||||
mask.draw_circle({255}, rad, rad, rad, VImage::option()->set("fill", true));
|
||||
|
@ -53,9 +46,8 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
|
||||
auto findResult = fontPaths.find(font);
|
||||
if (findResult != fontPaths.end()) {
|
||||
VImage::text(
|
||||
".", VImage::option()->set("fontfile",
|
||||
(basePath + findResult->second).c_str()));
|
||||
VImage::text(".", VImage::option()->set(
|
||||
"fontfile", (basePath + findResult->second).c_str()));
|
||||
}
|
||||
|
||||
VImage topText;
|
||||
|
@ -76,15 +68,13 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
topIn.morph(mask, VIPS_OPERATION_MORPHOLOGY_DILATE)
|
||||
.gaussblur(0.5, VImage::option()->set("min_ampl", 0.1));
|
||||
if (dividedWidth >= 1) {
|
||||
topOutline =
|
||||
topOutline.morph(altMask, VIPS_OPERATION_MORPHOLOGY_DILATE);
|
||||
topOutline = topOutline.morph(altMask, VIPS_OPERATION_MORPHOLOGY_DILATE);
|
||||
}
|
||||
topOutline = (topOutline == zeroVec);
|
||||
VImage topInvert = topOutline.extract_band(3).invert();
|
||||
topOutline =
|
||||
topOutline
|
||||
.extract_band(0,
|
||||
VImage::option()->set("n", topOutline.bands() - 1))
|
||||
.extract_band(0, VImage::option()->set("n", topOutline.bands() - 1))
|
||||
.bandjoin(topInvert);
|
||||
topText = topOutline.composite2(topIn, VIPS_BLEND_MODE_OVER);
|
||||
}
|
||||
|
@ -111,9 +101,10 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
bottomOutline = (bottomOutline == zeroVec);
|
||||
VImage bottomInvert = bottomOutline.extract_band(3).invert();
|
||||
bottomOutline = bottomOutline
|
||||
.extract_band(0, VImage::option()->set(
|
||||
"n", bottomOutline.bands() - 1))
|
||||
bottomOutline =
|
||||
bottomOutline
|
||||
.extract_band(0,
|
||||
VImage::option()->set("n", bottomOutline.bands() - 1))
|
||||
.bandjoin(bottomInvert);
|
||||
bottomText = bottomOutline.composite2(bottomIn, VIPS_BLEND_MODE_OVER);
|
||||
}
|
||||
|
@ -140,21 +131,12 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
final.set(VIPS_META_PAGE_HEIGHT, pageHeight);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
final.write_to_buffer(
|
||||
("." + type).c_str(), &buf, &length,
|
||||
("." + type).c_str(), &buf, DataSize,
|
||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||
: 0);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", type);
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Meme(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Meme(string type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,31 +1,23 @@
|
|||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Mirror(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
bool vertical = obj.Has("vertical")
|
||||
? obj.Get("vertical").As<Napi::Boolean>().Value()
|
||||
: false;
|
||||
bool first =
|
||||
obj.Has("first") ? obj.Get("first").As<Napi::Boolean>().Value() : false;
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
char *Mirror(string type, char *BufferData, size_t BufferLength,
|
||||
ArgumentMap Arguments, size_t *DataSize) {
|
||||
bool vertical = GetArgumentWithFallback<bool>(Arguments, "vertical", false);
|
||||
bool first = GetArgumentWithFallback<bool>(Arguments, "first", false);
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
VImage in =
|
||||
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||
type == "gif" ? options->set("n", -1) : options)
|
||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||
if (!in.has_alpha())
|
||||
in = in.bandjoin(255);
|
||||
|
||||
VImage out;
|
||||
|
||||
|
@ -67,18 +59,9 @@ Napi::Value Mirror(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", type);
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, DataSize);
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Mirror(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Mirror(string type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,28 +1,21 @@
|
|||
#include "common.h"
|
||||
#include <napi.h>
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string top_text = obj.Get("top").As<Napi::String>().Utf8Value();
|
||||
string bottom_text = obj.Get("bottom").As<Napi::String>().Utf8Value();
|
||||
string font = obj.Get("font").As<Napi::String>().Utf8Value();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
|
||||
char *Motivate(string type, char *BufferData, size_t BufferLength,
|
||||
ArgumentMap Arguments, size_t *DataSize) {
|
||||
string top_text = GetArgument<string>(Arguments, "top");
|
||||
string bottom_text = GetArgument<string>(Arguments, "bottom");
|
||||
string font = GetArgument<string>(Arguments, "font");
|
||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
VImage in =
|
||||
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||
type == "gif" ? options->set("n", -1) : options)
|
||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||
if (!in.has_alpha())
|
||||
|
@ -39,9 +32,8 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
|||
|
||||
auto findResult = fontPaths.find(font);
|
||||
if (findResult != fontPaths.end()) {
|
||||
VImage::text(
|
||||
".", VImage::option()->set("fontfile",
|
||||
(basePath + findResult->second).c_str()));
|
||||
VImage::text(".", VImage::option()->set(
|
||||
"fontfile", (basePath + findResult->second).c_str()));
|
||||
}
|
||||
|
||||
VImage topImage;
|
||||
|
@ -86,8 +78,8 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
|||
img_frame.embed(borderSize, borderSize, width + (borderSize * 2),
|
||||
pageHeight + (borderSize * 2),
|
||||
VImage::option()->set("extend", "black"));
|
||||
VImage bordered2 = bordered.embed(
|
||||
borderSize2, borderSize2, bordered.width() + (borderSize2 * 2),
|
||||
VImage bordered2 = bordered.embed(borderSize2, borderSize2,
|
||||
bordered.width() + (borderSize2 * 2),
|
||||
bordered.height() + (borderSize2 * 2),
|
||||
VImage::option()->set("extend", "white"));
|
||||
|
||||
|
@ -125,20 +117,10 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
|||
final.set(VIPS_META_PAGE_HEIGHT, height);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
final.write_to_buffer(("." + type).c_str(), &buf, &length,
|
||||
type == "gif" ? VImage::option()->set("dither", 1)
|
||||
: 0);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", type);
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
final.write_to_buffer(("." + type).c_str(), &buf, DataSize,
|
||||
type == "gif" ? VImage::option()->set("dither", 1) : 0);
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Motivate(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Motivate(string type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,25 +1,20 @@
|
|||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Reddit(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
char *Reddit(string type, char *BufferData, size_t BufferLength,
|
||||
ArgumentMap Arguments, size_t *DataSize) {
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string text = obj.Get("caption").As<Napi::String>().Utf8Value();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
|
||||
string text = GetArgument<string>(Arguments, "text");
|
||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
VImage in =
|
||||
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||
type == "gif" ? options->set("n", -1) : options)
|
||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||
if (!in.has_alpha())
|
||||
|
@ -64,21 +59,12 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
|
|||
final.set(VIPS_META_PAGE_HEIGHT, pageHeight + watermark.height());
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
final.write_to_buffer(
|
||||
("." + type).c_str(), &buf, &length,
|
||||
("." + type).c_str(), &buf, DataSize,
|
||||
type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||
: 0);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", type);
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Reddit(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Reddit(string type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,28 +1,19 @@
|
|||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Resize(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
bool stretch = obj.Has("stretch")
|
||||
? obj.Get("stretch").As<Napi::Boolean>().Value()
|
||||
: false;
|
||||
bool wide =
|
||||
obj.Has("wide") ? obj.Get("wide").As<Napi::Boolean>().Value() : false;
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
char *Resize(string type, char *BufferData, size_t BufferLength,
|
||||
ArgumentMap Arguments, size_t *DataSize) {
|
||||
bool stretch = GetArgumentWithFallback<bool>(Arguments, "stretch", false);
|
||||
bool wide = GetArgumentWithFallback<bool>(Arguments, "wide", false);
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
VImage in =
|
||||
VImage::new_from_buffer(data.Data(), data.Length(), "",
|
||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||
type == "gif" ? options->set("n", -1) : options)
|
||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||
|
||||
|
@ -34,8 +25,8 @@ Napi::Value Resize(const Napi::CallbackInfo &info) {
|
|||
|
||||
int finalHeight;
|
||||
if (stretch) {
|
||||
out = in.resize(
|
||||
512.0 / (double)width,
|
||||
out =
|
||||
in.resize(512.0 / (double)width,
|
||||
VImage::option()->set("vscale", 512.0 / (double)pageHeight));
|
||||
finalHeight = 512;
|
||||
} else if (wide) {
|
||||
|
@ -57,18 +48,9 @@ Napi::Value Resize(const Napi::CallbackInfo &info) {
|
|||
out.set(VIPS_META_PAGE_HEIGHT, finalHeight);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", type);
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, DataSize);
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Resize(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Resize(string type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,24 +1,19 @@
|
|||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Reverse(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
bool soos =
|
||||
obj.Has("soos") ? obj.Get("soos").As<Napi::Boolean>().Value() : false;
|
||||
char *Reverse(string type, char *BufferData, size_t BufferLength,
|
||||
ArgumentMap Arguments, size_t *DataSize) {
|
||||
bool soos = GetArgumentWithFallback<bool>(Arguments, "soos", false);
|
||||
|
||||
VOption *options =
|
||||
VImage::option()->set("access", "sequential")->set("n", -1);
|
||||
|
||||
VImage in = VImage::new_from_buffer(data.Data(), data.Length(), "", options)
|
||||
VImage in = VImage::new_from_buffer(BufferData, BufferLength, "", options)
|
||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||
|
||||
int width = in.width();
|
||||
|
@ -26,7 +21,8 @@ Napi::Value Reverse(const Napi::CallbackInfo &info) {
|
|||
int nPages = vips_image_get_n_pages(in.get_image());
|
||||
|
||||
vector<VImage> split;
|
||||
// todo: find a better way of getting individual frames (or at least getting the frames in reverse order)
|
||||
// todo: find a better way of getting individual frames (or at least getting
|
||||
// the frames in reverse order)
|
||||
for (int i = 0; i < nPages; i++) {
|
||||
VImage img_frame = in.crop(0, i * pageHeight, width, pageHeight);
|
||||
split.push_back(img_frame);
|
||||
|
@ -54,19 +50,12 @@ Napi::Value Reverse(const Napi::CallbackInfo &info) {
|
|||
final.set("delay", delays);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
final.write_to_buffer(".gif", &buf, &length,
|
||||
final.write_to_buffer(".gif", &buf, DataSize,
|
||||
VImage::option()->set("dither", 0));
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", "gif");
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
type = "gif";
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Reverse(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Reverse(string type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,30 +1,25 @@
|
|||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
#include <vips/vips8>
|
||||
|
||||
using namespace std;
|
||||
using namespace vips;
|
||||
|
||||
Napi::Value Sonic(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
try {
|
||||
Napi::Object obj = info[1].As<Napi::Object>();
|
||||
string text = obj.Get("text").As<Napi::String>().Utf8Value();
|
||||
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
|
||||
char *Sonic(string *type, ArgumentMap Arguments, size_t *DataSize) {
|
||||
string text = GetArgument<string>(Arguments, "text");
|
||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||
|
||||
string assetPath = basePath + "assets/images/sonic.jpg";
|
||||
VImage bg = VImage::new_from_file(assetPath.c_str());
|
||||
|
||||
VImage textImage =
|
||||
VImage::text(("<span foreground=\"white\">" + text + "</span>").c_str(),
|
||||
VImage::text(
|
||||
("<span foreground=\"white\">" + text + "</span>").c_str(),
|
||||
VImage::option()
|
||||
->set("rgba", true)
|
||||
->set("align", VIPS_ALIGN_CENTRE)
|
||||
->set("font", "Verdana, Twemoji Color Font")
|
||||
->set("fontfile",
|
||||
(basePath + "assets/fonts/twemoji.otf").c_str())
|
||||
->set("fontfile", (basePath + "assets/fonts/twemoji.otf").c_str())
|
||||
->set("width", 542)
|
||||
->set("height", 390))
|
||||
.gravity(VIPS_COMPASS_DIRECTION_CENTRE, 542, 390);
|
||||
|
@ -33,18 +28,11 @@ Napi::Value Sonic(const Napi::CallbackInfo &info) {
|
|||
VImage::option()->set("x", 391)->set("y", 84));
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
out.write_to_buffer(".png", &buf, &length);
|
||||
out.write_to_buffer(".png", &buf, DataSize);
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, (char *)buf, length));
|
||||
result.Set("type", "png");
|
||||
} catch (std::exception const &err) {
|
||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||
} catch (...) {
|
||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||
}
|
||||
*type = "png";
|
||||
|
||||
vips_error_clear();
|
||||
vips_thread_shutdown();
|
||||
return result;
|
||||
return (char *)buf;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <napi.h>
|
||||
#include "common.h"
|
||||
|
||||
Napi::Value Sonic(const Napi::CallbackInfo& info);
|
||||
using std::string;
|
||||
|
||||
char* Sonic(string *type, ArgumentMap Arguments, size_t *DataSize);
|
Loading…
Reference in a new issue