Changed image function syntax, improved dice, switched to fs.promises, might have also done other stuff but idk

This commit is contained in:
TheEssem 2020-08-27 21:34:12 -05:00
parent 95846d32d4
commit f415b3bb09
91 changed files with 1275 additions and 577 deletions

View file

@ -12,24 +12,19 @@ class BlurWorker : public Napi::AsyncWorker {
~BlurWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> blurred;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
for (Image &image : coalesced) {
if (sharp) {
image.sharpen(10, 3);
} else {
image.blur(15);
}
image.magick(type);
blurred.push_back(image);
if (sharp) {
for_each(coalesced.begin(), coalesced.end(), sharpenImage(10, 3));
} else {
for_each(coalesced.begin(), coalesced.end(), blurImage(15));
}
optimizeImageLayers(&result, blurred.begin(), blurred.end());
optimizeImageLayers(&result, coalesced.begin(), coalesced.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
}
@ -49,13 +44,14 @@ Napi::Value Blur(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
bool sharp = info[1].As<Napi::Boolean>().Value();
string type = info[2].As<Napi::String>().Utf8Value();
int delay = info[3].As<Napi::Number>().Int32Value();
Napi::Function cb = info[4].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
bool sharp = obj.Get("sharp").As<Napi::Boolean>().Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
BlurWorker* blurWorker = new BlurWorker(cb, in_path, sharp, type, delay);
BlurWorker* blurWorker = new BlurWorker(cb, path, sharp, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class BlurpleWorker : public Napi::AsyncWorker {
~BlurpleWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> blurpled;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> blurpled;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -45,12 +45,13 @@ Napi::Value Blurple(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
BlurpleWorker* blurpleWorker = new BlurpleWorker(cb, in_path, type, delay);
BlurpleWorker* blurpleWorker = new BlurpleWorker(cb, path, type, delay);
blurpleWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class CaptionWorker : public Napi::AsyncWorker {
~CaptionWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> captioned;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> captioned;
list <Image> result;
Blob caption_blob;
readImages(&frames, in_path);
@ -34,7 +34,7 @@ class CaptionWorker : public Napi::AsyncWorker {
for (Image &image : coalesced) {
Image appended;
list<Image> images;
list <Image> images;
image.backgroundColor("white");
images.push_back(caption_image);
images.push_back(image);
@ -62,13 +62,14 @@ Napi::Value Caption(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string caption = info[0].As<Napi::String>().Utf8Value();
string in_path = info[1].As<Napi::String>().Utf8Value();
string type = info[2].As<Napi::String>().Utf8Value();
int delay = info[3].As<Napi::Number>().Int32Value();
Napi::Function cb = info[4].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
CaptionWorker* captionWorker = new CaptionWorker(cb, caption, in_path, type, delay);
CaptionWorker* captionWorker = new CaptionWorker(cb, caption, path, type, delay);
captionWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class CaptionTwoWorker : public Napi::AsyncWorker {
~CaptionTwoWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> captioned;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> captioned;
list <Image> result;
Blob caption_blob;
readImages(&frames, in_path);
@ -32,7 +32,7 @@ class CaptionTwoWorker : public Napi::AsyncWorker {
for (Image &image : coalesced) {
Image appended;
list<Image> images;
list <Image> images;
image.backgroundColor("white");
images.push_back(image);
images.push_back(caption_image);
@ -60,13 +60,14 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string caption = info[0].As<Napi::String>().Utf8Value();
string in_path = info[1].As<Napi::String>().Utf8Value();
string type = info[2].As<Napi::String>().Utf8Value();
int delay = info[3].As<Napi::Number>().Int32Value();
Napi::Function cb = info[4].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
CaptionTwoWorker* captionTwoWorker = new CaptionTwoWorker(cb, caption, in_path, type, delay);
CaptionTwoWorker* captionTwoWorker = new CaptionTwoWorker(cb, caption, path, type, delay);
captionTwoWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class CircleWorker : public Napi::AsyncWorker {
~CircleWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> blurred;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> blurred;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -44,12 +44,13 @@ Napi::Value Circle(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
CircleWorker* circleWorker = new CircleWorker(cb, in_path, type, delay);
CircleWorker* circleWorker = new CircleWorker(cb, path, type, delay);
circleWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class CropWorker : public Napi::AsyncWorker {
~CropWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -45,12 +45,13 @@ Napi::Value Crop(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
CropWorker* blurWorker = new CropWorker(cb, in_path, type, delay);
CropWorker* blurWorker = new CropWorker(cb, path, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -44,13 +44,14 @@ Napi::Value Explode(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
int amount = info[1].As<Napi::Number>().Int32Value();
string type = info[2].As<Napi::String>().Utf8Value();
int delay = info[3].As<Napi::Number>().Int32Value();
Napi::Function cb = info[4].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
int amount = obj.Get("amount").As<Napi::Number>().Int32Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
ExplodeWorker* explodeWorker = new ExplodeWorker(cb, in_path, amount, type, delay);
ExplodeWorker* explodeWorker = new ExplodeWorker(cb, path, amount, type, delay);
explodeWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class FlagWorker : public Napi::AsyncWorker {
~FlagWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read(overlay_path);
@ -50,13 +50,14 @@ Napi::Value Flag(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string overlay_path = info[1].As<Napi::String>().Utf8Value();
string type = info[2].As<Napi::String>().Utf8Value();
int delay = info[3].As<Napi::Number>().Int32Value();
Napi::Function cb = info[4].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string overlay = obj.Get("overlay").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
FlagWorker* flagWorker = new FlagWorker(cb, in_path, overlay_path, type, delay);
FlagWorker* flagWorker = new FlagWorker(cb, path, overlay, type, delay);
flagWorker->Queue();
return env.Undefined();
}

View file

@ -7,20 +7,20 @@ using namespace Magick;
class FlipWorker : public Napi::AsyncWorker {
public:
FlipWorker(Napi::Function& callback, string in_path, string type, int delay)
: Napi::AsyncWorker(callback), in_path(in_path), type(type), delay(delay) {}
FlipWorker(Napi::Function& callback, string in_path, bool flop, string type, int delay)
: Napi::AsyncWorker(callback), in_path(in_path), flop(flop), type(type), delay(delay) {}
~FlipWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
for (Image &image : coalesced) {
image.flip();
flop ? image.flop() : image.flip();
image.magick(type);
mid.push_back(image);
}
@ -36,6 +36,7 @@ class FlipWorker : public Napi::AsyncWorker {
private:
string in_path, type;
bool flop;
int delay;
Blob blob;
};
@ -44,12 +45,14 @@ Napi::Value Flip(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
bool flop = obj.Has("flop") ? obj.Get("flop").As<Napi::Boolean>().Value() : false;
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
FlipWorker* flipWorker = new FlipWorker(cb, in_path, type, delay);
FlipWorker* flipWorker = new FlipWorker(cb, path, flop, type, delay);
flipWorker->Queue();
return env.Undefined();
}

View file

@ -1,55 +0,0 @@
#include <napi.h>
#include <list>
#include <Magick++.h>
using namespace std;
using namespace Magick;
class FlopWorker : public Napi::AsyncWorker {
public:
FlopWorker(Napi::Function& callback, string in_path, string type, int delay)
: Napi::AsyncWorker(callback), in_path(in_path), type(type), delay(delay) {}
~FlopWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
for (Image &image : coalesced) {
image.flop();
image.magick(type);
mid.push_back(image);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
}
void OnOK() {
Callback().Call({Env().Undefined(), Napi::Buffer<char>::Copy(Env(), (char *)blob.data(), blob.length())});
}
private:
string in_path, type;
int delay;
Blob blob;
};
Napi::Value Flop(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
FlopWorker* flopWorker = new FlopWorker(cb, in_path, type, delay);
flopWorker->Queue();
return env.Undefined();
}

View file

@ -1,8 +0,0 @@
#ifndef ESMBOT_NATIVES_FLOP_H_
#define ESMBOT_NATIVES_FLOP_H_
#include <napi.h>
Napi::Value Flop(const Napi::CallbackInfo& info);
#endif

View file

@ -12,7 +12,7 @@ class FreezeWorker : public Napi::AsyncWorker {
~FreezeWorker() {}
void Execute() {
list<Image> frames;
list <Image> frames;
readImages(&frames, in_path);
for_each(frames.begin(), frames.end(), animationIterationsImage(loop ? 0 : 1));
@ -36,13 +36,14 @@ Napi::Value Freeze(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
bool loop = info[1].As<Napi::Boolean>().Value();
string type = info[2].As<Napi::String>().Utf8Value();
int delay = info[3].As<Napi::Number>().Int32Value();
Napi::Function cb = info[4].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
bool loop = obj.Has("loop") ? obj.Get("loop").As<Napi::Boolean>().Value() : false;
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
FreezeWorker* blurWorker = new FreezeWorker(cb, in_path, loop, type, delay);
FreezeWorker* blurWorker = new FreezeWorker(cb, path, loop, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class GamexplainWorker : public Napi::AsyncWorker {
~GamexplainWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read("./assets/images/gamexplain.png");
@ -49,12 +49,13 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
GamexplainWorker* blurWorker = new GamexplainWorker(cb, in_path, type, delay);
GamexplainWorker* blurWorker = new GamexplainWorker(cb, path, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class GlobeWorker : public Napi::AsyncWorker {
~GlobeWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image distort;
Image overlay;
readImages(&frames, in_path);
@ -24,7 +24,7 @@ class GlobeWorker : public Napi::AsyncWorker {
coalesceImages(&coalesced, frames.begin(), frames.end());
if (type != "GIF") {
list<Image>::iterator it = coalesced.begin();
list <Image>::iterator it = coalesced.begin();
for (int i = 0; i < 29; ++i) {
coalesced.push_back(*it);
}
@ -66,12 +66,13 @@ Napi::Value Globe(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
GlobeWorker* blurWorker = new GlobeWorker(cb, in_path, type, delay);
GlobeWorker* blurWorker = new GlobeWorker(cb, path, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -1,4 +1,5 @@
#include <napi.h>
#include <list>
#include <Magick++.h>
using namespace std;
@ -36,10 +37,11 @@ Napi::Value Homebrew(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string text = info[0].As<Napi::String>().Utf8Value();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
HomebrewWorker* explodeWorker = new HomebrewWorker(cb, text);
HomebrewWorker* explodeWorker = new HomebrewWorker(cb, caption);
explodeWorker->Queue();
return env.Undefined();
}

View file

@ -1,4 +1,5 @@
#include <napi.h>
#include <list>
#include "blur.h"
#include "blurple.h"
#include "caption.h"
@ -8,7 +9,6 @@
#include "explode.h"
#include "flag.h"
#include "flip.h"
#include "flop.h"
#include "freeze.h"
#include "gamexplain.h"
#include "globe.h"
@ -45,7 +45,6 @@ Napi::Object Init(Napi::Env env, Napi::Object exports)
exports.Set(Napi::String::New(env, "explode"), Napi::Function::New(env, Explode));
exports.Set(Napi::String::New(env, "flag"), Napi::Function::New(env, Flag));
exports.Set(Napi::String::New(env, "flip"), Napi::Function::New(env, Flip));
exports.Set(Napi::String::New(env, "flop"), Napi::Function::New(env, Flop));
exports.Set(Napi::String::New(env, "freeze"), Napi::Function::New(env, Freeze));
exports.Set(Napi::String::New(env, "gamexplain"), Napi::Function::New(env, Gamexplain));
exports.Set(Napi::String::New(env, "globe"), Napi::Function::New(env, Globe));

View file

@ -12,20 +12,16 @@ class InvertWorker : public Napi::AsyncWorker {
~InvertWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> inverted;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
for (Image &image : coalesced) {
image.negateChannel(Magick::ChannelType(Magick::CompositeChannels ^ Magick::AlphaChannel));
image.magick(type);
inverted.push_back(image);
}
for_each(coalesced.begin(), coalesced.end(), negateImage(Magick::ChannelType(Magick::CompositeChannels ^ Magick::AlphaChannel)));
for_each(coalesced.begin(), coalesced.end(), magickImage(type));
optimizeImageLayers(&result, inverted.begin(), inverted.end());
optimizeImageLayers(&result, coalesced.begin(), coalesced.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
}
@ -44,12 +40,13 @@ Napi::Value Invert(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
InvertWorker* invertWorker = new InvertWorker(cb, in_path, type, delay);
InvertWorker* invertWorker = new InvertWorker(cb, path, type, delay);
invertWorker->Queue();
return env.Undefined();
}

View file

@ -1,4 +1,5 @@
#include <napi.h>
#include <list>
#include <Magick++.h>
using namespace std;
@ -31,10 +32,11 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
JpegWorker* explodeWorker = new JpegWorker(cb, in_path);
JpegWorker* explodeWorker = new JpegWorker(cb, path);
explodeWorker->Queue();
return env.Undefined();
}

View file

@ -12,9 +12,9 @@ class LeakWorker : public Napi::AsyncWorker {
~LeakWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
Image watermark;
readImages(&frames, in_path);
watermark.read("./assets/images/leak.png");
@ -48,12 +48,13 @@ Napi::Value Leak(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
LeakWorker* blurWorker = new LeakWorker(cb, in_path, type, delay);
LeakWorker* blurWorker = new LeakWorker(cb, path, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class MagikWorker : public Napi::AsyncWorker {
~MagikWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> blurred;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> blurred;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -46,12 +46,14 @@ Napi::Value Magik(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
MagikWorker* explodeWorker = new MagikWorker(cb, in_path, type, delay);
MagikWorker* explodeWorker = new MagikWorker(cb, path, type, delay);
explodeWorker->Queue();
return env.Undefined();
}

View file

@ -12,9 +12,9 @@ class MemeWorker : public Napi::AsyncWorker {
~MemeWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
Image top_text;
Image bottom_text;
readImages(&frames, in_path);
@ -74,14 +74,15 @@ Napi::Value Meme(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string text_top = info[1].As<Napi::String>().Utf8Value();
string text_bottom = info[2].As<Napi::String>().Utf8Value();
string type = info[3].As<Napi::String>().Utf8Value();
int delay = info[4].As<Napi::Number>().Int32Value();
Napi::Function cb = info[5].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string top = obj.Get("top").As<Napi::String>().Utf8Value();
string bottom = obj.Get("bottom").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
MemeWorker* blurWorker = new MemeWorker(cb, in_path, text_top, text_bottom, type, delay);
MemeWorker* blurWorker = new MemeWorker(cb, path, top, bottom, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class MirrorWorker : public Napi::AsyncWorker {
~MirrorWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
MagickCore::GravityType gravity;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -31,7 +31,7 @@ class MirrorWorker : public Napi::AsyncWorker {
}
for (Image &image : coalesced) {
list<Image> mirrored;
list <Image> mirrored;
Image final;
image.extent(Geometry(to_string(vertical ? image.baseColumns() : image.baseColumns() / 2) + "x" + to_string(vertical ? image.baseRows() / 2 : image.baseRows())), gravity);
mirrored.push_back(image);
@ -71,14 +71,15 @@ Napi::Value Mirror(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
bool vertical = info[1].As<Napi::Boolean>().Value();
bool first = info[2].As<Napi::Boolean>().Value();
string type = info[3].As<Napi::String>().Utf8Value();
int delay = info[4].As<Napi::Number>().Int32Value();
Napi::Function cb = info[5].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
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();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
MirrorWorker* mirrorWorker = new MirrorWorker(cb, in_path, vertical, first, type, delay);
MirrorWorker* mirrorWorker = new MirrorWorker(cb, path, vertical, first, type, delay);
mirrorWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class SwirlWorker : public Napi::AsyncWorker {
~SwirlWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -44,12 +44,13 @@ Napi::Value Swirl(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
SwirlWorker* flopWorker = new SwirlWorker(cb, in_path, type, delay);
SwirlWorker* flopWorker = new SwirlWorker(cb, path, type, delay);
flopWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class MotivateWorker : public Napi::AsyncWorker {
~MotivateWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image top;
Image bottom;
readImages(&frames, in_path);
@ -49,7 +49,7 @@ class MotivateWorker : public Napi::AsyncWorker {
image.backgroundColor("black");
image.extent(Geometry(600, image.rows() + 50), Magick::CenterGravity);
list<Image> to_append;
list <Image> to_append;
to_append.push_back(image);
to_append.push_back(top);
if (bottom_text != "") to_append.push_back(bottom);
@ -77,14 +77,15 @@ Napi::Value Motivate(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string top_text = info[1].As<Napi::String>().Utf8Value();
string bottom_text = info[2].As<Napi::String>().Utf8Value();
string type = info[3].As<Napi::String>().Utf8Value();
int delay = info[4].As<Napi::Number>().Int32Value();
Napi::Function cb = info[5].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string top = obj.Get("top").As<Napi::String>().Utf8Value();
string bottom = obj.Get("bottom").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
MotivateWorker* blurWorker = new MotivateWorker(cb, in_path, top_text, bottom_text, type, delay);
MotivateWorker* blurWorker = new MotivateWorker(cb, path, top, bottom, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -1,4 +1,5 @@
#include <napi.h>
#include <list>
#include <ZXing/ReadBarcode.h>
#include <ZXing/TextUtfEncoding.h>
@ -42,10 +43,11 @@ Napi::Value QrRead(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
QrReadWorker* qrReadWorker = new QrReadWorker(cb, in_path);
QrReadWorker* qrReadWorker = new QrReadWorker(cb, path);
qrReadWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class ResizeWorker : public Napi::AsyncWorker {
~ResizeWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> blurred;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> blurred;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -52,14 +52,15 @@ Napi::Value Resize(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
bool stretch = info[1].As<Napi::Boolean>().Value();
bool wide = info[2].As<Napi::Boolean>().Value();
string type = info[3].As<Napi::String>().Utf8Value();
int delay = info[4].As<Napi::Number>().Int32Value();
Napi::Function cb = info[5].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
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();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
ResizeWorker* explodeWorker = new ResizeWorker(cb, in_path, stretch, wide, type, delay);
ResizeWorker* explodeWorker = new ResizeWorker(cb, path, stretch, wide, type, delay);
explodeWorker->Queue();
return env.Undefined();
}

View file

@ -1,5 +1,6 @@
#include <napi.h>
#include <list>
#include <list>
#include <Magick++.h>
using namespace std;
@ -46,12 +47,13 @@ Napi::Value Reverse(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
bool soos = info[1].As<Napi::Boolean>().Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
bool soos = obj.Has("soos") ? obj.Get("soos").As<Napi::Boolean>().Value() : false;
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
ReverseWorker* explodeWorker = new ReverseWorker(cb, in_path, soos, delay);
ReverseWorker* explodeWorker = new ReverseWorker(cb, path, soos, delay);
explodeWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class ScottWorker : public Napi::AsyncWorker {
~ScottWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read("./assets/images/scott.png");
@ -53,12 +53,13 @@ Napi::Value Scott(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
ScottWorker* blurWorker = new ScottWorker(cb, in_path, type, delay);
ScottWorker* blurWorker = new ScottWorker(cb, path, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -41,8 +41,9 @@ Napi::Value Sonic(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string text = info[0].As<Napi::String>().Utf8Value();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string text = obj.Get("path").As<Napi::String>().Utf8Value();
SonicWorker* explodeWorker = new SonicWorker(cb, text);
explodeWorker->Queue();

View file

@ -12,8 +12,8 @@ class SpeedWorker : public Napi::AsyncWorker {
~SpeedWorker() {}
void Execute() {
list<Image> frames;
list<Image> blurred;
list <Image> frames;
list <Image> blurred;
readImages(&frames, in_path);
int new_delay = slow ? delay * 2 : delay / 2;
@ -43,13 +43,14 @@ Napi::Value Speed(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
bool slow = info[1].As<Napi::Boolean>().Value();
string type = info[2].As<Napi::String>().Utf8Value();
int delay = info[3].As<Napi::Number>().Int32Value();
Napi::Function cb = info[4].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
bool slow = obj.Has("slow") ? obj.Get("slow").As<Napi::Boolean>().Value() : false;
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
SpeedWorker* explodeWorker = new SpeedWorker(cb, in_path, slow, type, delay);
SpeedWorker* explodeWorker = new SpeedWorker(cb, path, slow, type, delay);
explodeWorker->Queue();
return env.Undefined();
}

View file

@ -12,15 +12,15 @@ class SpinWorker : public Napi::AsyncWorker {
~SpinWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
if (type != "GIF") {
list<Image>::iterator it = coalesced.begin();
list <Image>::iterator it = coalesced.begin();
for (int i = 0; i < 29; ++i) {
coalesced.push_back(*it);
}
@ -60,12 +60,13 @@ Napi::Value Spin(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
SpinWorker* blurWorker = new SpinWorker(cb, in_path, type, delay);
SpinWorker* blurWorker = new SpinWorker(cb, path, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -12,17 +12,17 @@ class TileWorker : public Napi::AsyncWorker {
~TileWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
for (Image &image : coalesced) {
list<Image> duplicated;
list <Image> duplicated;
Image appended;
list<Image> montage;
list <Image> montage;
Image frame;
image.magick(type);
for (int i = 0; i < 5; ++i) {
@ -56,12 +56,13 @@ Napi::Value Tile(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
TileWorker* flopWorker = new TileWorker(cb, in_path, type, delay);
TileWorker* flopWorker = new TileWorker(cb, path, type, delay);
flopWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class TrumpWorker : public Napi::AsyncWorker {
~TrumpWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read("./assets/images/trump.png");
@ -53,12 +53,13 @@ Napi::Value Trump(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
TrumpWorker* blurWorker = new TrumpWorker(cb, in_path, type, delay);
TrumpWorker* blurWorker = new TrumpWorker(cb, path, type, delay);
blurWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class WallWorker : public Napi::AsyncWorker {
~WallWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -50,12 +50,13 @@ Napi::Value Wall(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
WallWorker* flopWorker = new WallWorker(cb, in_path, type, delay);
WallWorker* flopWorker = new WallWorker(cb, path, type, delay);
flopWorker->Queue();
return env.Undefined();
}

View file

@ -1,5 +1,6 @@
#include <napi.h>
#include <list>
#include <iostream>
#include <Magick++.h>
using namespace std;
@ -7,15 +8,15 @@ using namespace Magick;
class WatermarkWorker : public Napi::AsyncWorker {
public:
WatermarkWorker(Napi::Function& callback, string in_path, string water_path, int gravity, bool resize, bool append, bool mc, string type, int delay)
: Napi::AsyncWorker(callback), in_path(in_path), water_path(water_path), gravity(gravity), resize(resize), append(append), mc(mc), type(type), delay(delay) {}
WatermarkWorker(Napi::Function& callback, string in_path, string water_path, int gravity, string type, int delay, bool resize, bool append, bool mc)
: Napi::AsyncWorker(callback), in_path(in_path), water_path(water_path), gravity(gravity), type(type), delay(delay), resize(resize), append(append), mc(mc) {}
~WatermarkWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read(water_path);
@ -31,7 +32,7 @@ class WatermarkWorker : public Napi::AsyncWorker {
for (Image &image : coalesced) {
Image final;
if (append) {
list<Image> to_append;
list <Image> to_append;
to_append.push_back(image);
to_append.push_back(watermark);
appendImages(&final, to_append.begin(), to_append.end(), true);
@ -68,17 +69,18 @@ Napi::Value Watermark(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string water = info[1].As<Napi::String>().Utf8Value();
int gravity = info[2].As<Napi::Number>().Int32Value();
bool resize = info[3].As<Napi::Boolean>().Value();
bool append = info[4].As<Napi::Boolean>().Value();
bool mc = info[5].As<Napi::Boolean>().Value();
string type = info[6].As<Napi::String>().Utf8Value();
int delay = info[7].As<Napi::Number>().Int32Value();
Napi::Function cb = info[8].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string water = obj.Get("water").As<Napi::String>().Utf8Value();
int gravity = obj.Get("gravity").As<Napi::Number>().Int32Value();
bool resize = obj.Has("resize") ? obj.Get("resize").As<Napi::Boolean>().Value() : false;
bool append = obj.Has("append") ? obj.Get("append").As<Napi::Boolean>().Value() : false;
bool mc = obj.Has("mc") ? obj.Get("mc").As<Napi::Boolean>().Value() : false;
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
WatermarkWorker* watermarkWorker = new WatermarkWorker(cb, in_path, water, gravity, resize, append, mc, type, delay);
WatermarkWorker* watermarkWorker = new WatermarkWorker(cb, path, water, gravity, type, delay, resize, append, mc);
watermarkWorker->Queue();
return env.Undefined();
}

View file

@ -12,10 +12,10 @@ class WdtWorker : public Napi::AsyncWorker {
~WdtWorker() {}
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> mid;
list<Image> result;
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read("./assets/images/whodidthis.png");
@ -48,12 +48,13 @@ Napi::Value Wdt(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
string in_path = info[0].As<Napi::String>().Utf8Value();
string type = info[1].As<Napi::String>().Utf8Value();
int delay = info[2].As<Napi::Number>().Int32Value();
Napi::Function cb = info[3].As<Napi::Function>();
Napi::Object obj = info[0].As<Napi::Object>();
Napi::Function cb = info[1].As<Napi::Function>();
string path = obj.Get("path").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
int delay = obj.Get("delay").As<Napi::Number>().Int32Value();
WdtWorker* blurWorker = new WdtWorker(cb, in_path, type, delay);
WdtWorker* blurWorker = new WdtWorker(cb, path, type, delay);
blurWorker->Queue();
return env.Undefined();
}