Add initial Azure Functions support, clean up gitignore

This commit is contained in:
Essem 2022-04-17 10:40:56 -05:00
parent dd7bd6b4cc
commit 6bf0537c29
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
29 changed files with 267 additions and 65 deletions

View file

@ -15,6 +15,7 @@ Napi::Value Flag(const Napi::CallbackInfo &info) {
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
string overlay = obj.Get("overlay").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
int delay =
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
@ -31,7 +32,8 @@ Napi::Value Flag(const Napi::CallbackInfo &info) {
} catch (Magick::Warning &warning) {
cerr << "Warning: " << warning.what() << endl;
}
watermark.read(overlay);
string assetPath = basePath + overlay;
watermark.read(assetPath);
watermark.alphaChannel(Magick::SetAlphaChannel);
watermark.evaluate(Magick::AlphaChannel, Magick::MultiplyEvaluateOperator,
0.5);

View file

@ -14,6 +14,7 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
Napi::Object obj = info[0].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();
int delay =
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
@ -30,7 +31,8 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
} catch (Magick::Warning &warning) {
cerr << "Warning: " << warning.what() << endl;
}
watermark.read("./assets/images/gamexplain.png");
string assetPath = basePath + "assets/images/gamexplain.png";
watermark.read(assetPath);
coalesceImages(&coalesced, frames.begin(), frames.end());
for (Image &image : coalesced) {

View file

@ -14,6 +14,7 @@ Napi::Value Globe(const Napi::CallbackInfo &info) {
Napi::Object obj = info[0].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();
int delay =
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
@ -31,8 +32,8 @@ Napi::Value Globe(const Napi::CallbackInfo &info) {
} catch (Magick::Warning &warning) {
cerr << "Warning: " << warning.what() << endl;
}
distort.read("./assets/images/spheremap.png");
overlay.read("./assets/images/sphere_overlay.png");
distort.read(basePath + "assets/images/spheremap.png");
overlay.read(basePath + "assets/images/sphere_overlay.png");
coalesceImages(&coalesced, frames.begin(), frames.end());
if (type != "gif") {

View file

@ -12,11 +12,13 @@ Napi::Value Homebrew(const Napi::CallbackInfo &info) {
try {
Napi::Object obj = info[0].As<Napi::Object>();
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
Blob blob;
Image image;
image.read("./assets/images/hbc.png");
string assetPath = basePath + "assets/images/hbc.png";
image.read(assetPath);
image.textGravity(Magick::CenterGravity);
image.font("./assets/hbc.ttf");
image.textKerning(-5);

View file

@ -14,6 +14,7 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
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();
int delay =
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
@ -32,7 +33,7 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
cerr << "Warning: " << warning.what() << endl;
}
watermark.read("./assets/images/reddit.png");
watermark.read(basePath + "assets/images/reddit.png");
text_image.textGravity(Magick::WestGravity);
text_image.font("Roboto");
text_image.fontPointsize(47);

View file

@ -14,6 +14,7 @@ Napi::Value Retro(const Napi::CallbackInfo &info) {
string line1 = obj.Get("line1").As<Napi::String>().Utf8Value();
string line2 = obj.Get("line2").As<Napi::String>().Utf8Value();
string line3 = obj.Get("line3").As<Napi::String>().Utf8Value();
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
Blob blob;
@ -22,7 +23,7 @@ Napi::Value Retro(const Napi::CallbackInfo &info) {
Image line2_text;
Image line3_text;
image.read("./assets/images/retro.png");
image.read(basePath + "assets/images/retro.png");
line2_text.backgroundColor("none");
line2_text.fontPointsize(128);

View file

@ -14,6 +14,7 @@ Napi::Value Scott(const Napi::CallbackInfo &info) {
Napi::Object obj = info[0].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();
int delay =
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
@ -30,7 +31,7 @@ Napi::Value Scott(const Napi::CallbackInfo &info) {
} catch (Magick::Warning &warning) {
cerr << "Warning: " << warning.what() << endl;
}
watermark.read("./assets/images/scott.png");
watermark.read(basePath + "assets/images/scott.png");
coalesceImages(&coalesced, frames.begin(), frames.end());
for (Image &image : coalesced) {

View file

@ -12,6 +12,7 @@ Napi::Value Sonic(const Napi::CallbackInfo &info) {
try {
Napi::Object obj = info[0].As<Napi::Object>();
string text = obj.Get("text").As<Napi::String>().Utf8Value();
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
Blob blob;
@ -24,7 +25,7 @@ Napi::Value Sonic(const Napi::CallbackInfo &info) {
text_image.read("pango:<span foreground='white'>" + text + "</span>");
text_image.resize(Geometry(474, 332));
text_image.extent(Geometry("1024x538-435-145"), Magick::CenterGravity);
image.read("./assets/images/sonic.jpg");
image.read(basePath + "assets/images/sonic.jpg");
image.composite(text_image, Geometry("+160+10"), Magick::OverCompositeOp);
image.magick("PNG");
image.write(&blob);

View file

@ -26,6 +26,7 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
? obj.Get("append").As<Napi::Boolean>().Value()
: false;
bool mc = obj.Has("mc") ? obj.Get("mc").As<Napi::Boolean>().Value() : false;
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay =
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
@ -43,7 +44,8 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
} catch (Magick::Warning &warning) {
cerr << "Warning: " << warning.what() << endl;
}
watermark.read(water);
string merged = basePath + water;
watermark.read(merged);
if (resize && append) {
string query(to_string(frames.front().baseColumns()) + "x");
watermark.scale(Geometry(query));

View file

@ -14,6 +14,7 @@ Napi::Value Wdt(const Napi::CallbackInfo &info) {
Napi::Object obj = info[0].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();
int delay =
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
@ -30,7 +31,7 @@ Napi::Value Wdt(const Napi::CallbackInfo &info) {
} catch (Magick::Warning &warning) {
cerr << "Warning: " << warning.what() << endl;
}
watermark.read("./assets/images/whodidthis.png");
watermark.read(basePath + "assets/images/whodidthis.png");
coalesceImages(&coalesced, frames.begin(), frames.end());
for (Image &image : coalesced) {

View file

@ -13,6 +13,7 @@ Napi::Value Zamn(const Napi::CallbackInfo &info) {
Napi::Object obj = info[0].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();
int delay =
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
@ -23,7 +24,7 @@ Napi::Value Zamn(const Napi::CallbackInfo &info) {
list<Image> mid;
Image watermark;
readImages(&frames, Blob(data.Data(), data.Length()));
watermark.read("./assets/images/zamn.png");
watermark.read(basePath + "assets/images/zamn.png");
coalesceImages(&coalesced, frames.begin(), frames.end());
for (Image &image : coalesced) {