Pass an image buffer into the native functions instead of a URL
This commit is contained in:
parent
666f9b9912
commit
61758fa3bb
33 changed files with 81 additions and 75 deletions
|
@ -11,7 +11,7 @@ Napi::Value Blur(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
bool sharp = obj.Get("sharp").As<Napi::Boolean>().Value();
|
bool sharp = obj.Get("sharp").As<Napi::Boolean>().Value();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Blur(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
if (sharp) {
|
if (sharp) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Blurple(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Blurple(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> blurpled;
|
list<Image> blurpled;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for (Image &image : coalesced) {
|
for (Image &image : coalesced) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Caption(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
|
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
|
@ -22,7 +22,7 @@ Napi::Value Caption(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> captioned;
|
list<Image> captioned;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
|
|
||||||
size_t width = frames.front().baseColumns();
|
size_t width = frames.front().baseColumns();
|
||||||
string query(to_string(width - ((width / 25) * 2)) + "x");
|
string query(to_string(width - ((width / 25) * 2)) + "x");
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
|
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
|
@ -23,7 +23,7 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> captioned;
|
list<Image> captioned;
|
||||||
Blob caption_blob;
|
Blob caption_blob;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
|
|
||||||
size_t width = frames.front().baseColumns();
|
size_t width = frames.front().baseColumns();
|
||||||
string query(to_string(width - ((width / 25) * 2)) + "x");
|
string query(to_string(width - ((width / 25) * 2)) + "x");
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Circle(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Circle(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> blurred;
|
list<Image> blurred;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for (Image &image : coalesced) {
|
for (Image &image : coalesced) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Crop(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Crop(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for (Image &image : coalesced) {
|
for (Image &image : coalesced) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Explode(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
int amount = obj.Get("amount").As<Napi::Number>().Int32Value();
|
int amount = obj.Get("amount").As<Napi::Number>().Int32Value();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
|
@ -22,7 +22,7 @@ Napi::Value Explode(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> blurred;
|
list<Image> blurred;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for (Image &image : coalesced) {
|
for (Image &image : coalesced) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Flag(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string overlay = obj.Get("overlay").As<Napi::String>().Utf8Value();
|
string overlay = obj.Get("overlay").As<Napi::String>().Utf8Value();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
|
@ -23,7 +23,7 @@ Napi::Value Flag(const Napi::CallbackInfo &info) {
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image watermark;
|
Image watermark;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
watermark.read(overlay);
|
watermark.read(overlay);
|
||||||
watermark.alphaChannel(Magick::SetAlphaChannel);
|
watermark.alphaChannel(Magick::SetAlphaChannel);
|
||||||
watermark.evaluate(Magick::AlphaChannel, Magick::MultiplyEvaluateOperator,
|
watermark.evaluate(Magick::AlphaChannel, Magick::MultiplyEvaluateOperator,
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Flip(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
bool flop =
|
bool flop =
|
||||||
obj.Has("flop") ? obj.Get("flop").As<Napi::Boolean>().Value() : false;
|
obj.Has("flop") ? obj.Get("flop").As<Napi::Boolean>().Value() : false;
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
|
@ -23,7 +23,7 @@ Napi::Value Flip(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for (Image &image : coalesced) {
|
for (Image &image : coalesced) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
bool loop =
|
bool loop =
|
||||||
obj.Has("loop") ? obj.Get("loop").As<Napi::Boolean>().Value() : false;
|
obj.Has("loop") ? obj.Get("loop").As<Napi::Boolean>().Value() : false;
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
|
@ -24,7 +24,7 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
|
||||||
Blob blob;
|
Blob blob;
|
||||||
|
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
|
|
||||||
if (frame >= 0 && !loop) {
|
if (frame >= 0 && !loop) {
|
||||||
size_t frameSize = frames.size();
|
size_t frameSize = frames.size();
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -22,7 +22,7 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image watermark;
|
Image watermark;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
watermark.read("./assets/images/gamexplain.png");
|
watermark.read("./assets/images/gamexplain.png");
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Globe(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -23,7 +23,7 @@ Napi::Value Globe(const Napi::CallbackInfo &info) {
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image distort;
|
Image distort;
|
||||||
Image overlay;
|
Image overlay;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
distort.read("./assets/images/spheremap.png");
|
distort.read("./assets/images/spheremap.png");
|
||||||
overlay.read("./assets/images/sphere_overlay.png");
|
overlay.read("./assets/images/sphere_overlay.png");
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Invert(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Invert(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for_each(coalesced.begin(), coalesced.end(), negateImage());
|
for_each(coalesced.begin(), coalesced.end(), negateImage());
|
||||||
|
|
|
@ -11,12 +11,12 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
|
|
||||||
Blob blob;
|
Blob blob;
|
||||||
|
|
||||||
Image image;
|
Image image;
|
||||||
image.read(path);
|
image.read(Blob(data.Data(), data.Length()));
|
||||||
image.quality(1);
|
image.quality(1);
|
||||||
image.magick("JPEG");
|
image.magick("JPEG");
|
||||||
image.write(&blob);
|
image.write(&blob);
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Leak(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -22,7 +22,7 @@ Napi::Value Leak(const Napi::CallbackInfo &info) {
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image watermark;
|
Image watermark;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
watermark.read("./assets/images/leak.png");
|
watermark.read("./assets/images/leak.png");
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Magik(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Magik(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> blurred;
|
list<Image> blurred;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for (Image &image : coalesced) {
|
for (Image &image : coalesced) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string top = obj.Get("top").As<Napi::String>().Utf8Value();
|
string top = obj.Get("top").As<Napi::String>().Utf8Value();
|
||||||
string bottom = obj.Get("bottom").As<Napi::String>().Utf8Value();
|
string bottom = obj.Get("bottom").As<Napi::String>().Utf8Value();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
|
@ -25,7 +25,7 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image top_text;
|
Image top_text;
|
||||||
Image bottom_text;
|
Image bottom_text;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
for_each(coalesced.begin(), coalesced.end(),
|
for_each(coalesced.begin(), coalesced.end(),
|
||||||
scaleImage(Geometry(600, 600)));
|
scaleImage(Geometry(600, 600)));
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Mirror(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
bool vertical = obj.Has("vertical")
|
bool vertical = obj.Has("vertical")
|
||||||
? obj.Get("vertical").As<Napi::Boolean>().Value()
|
? obj.Get("vertical").As<Napi::Boolean>().Value()
|
||||||
: false;
|
: false;
|
||||||
|
@ -27,7 +27,7 @@ Napi::Value Mirror(const Napi::CallbackInfo &info) {
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
MagickCore::GravityType gravity;
|
MagickCore::GravityType gravity;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
if (vertical && first) {
|
if (vertical && first) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string top_text = obj.Get("top").As<Napi::String>().Utf8Value();
|
string top_text = obj.Get("top").As<Napi::String>().Utf8Value();
|
||||||
string bottom_text = obj.Get("bottom").As<Napi::String>().Utf8Value();
|
string bottom_text = obj.Get("bottom").As<Napi::String>().Utf8Value();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
|
@ -25,7 +25,7 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image top;
|
Image top;
|
||||||
Image bottom;
|
Image bottom;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
top.size(Geometry("600"));
|
top.size(Geometry("600"));
|
||||||
|
|
|
@ -10,7 +10,7 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string text = obj.Get("caption").As<Napi::String>().Utf8Value();
|
string text = obj.Get("caption").As<Napi::String>().Utf8Value();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
|
@ -23,7 +23,7 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image watermark;
|
Image watermark;
|
||||||
Image text_image;
|
Image text_image;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
|
|
||||||
watermark.read("./assets/images/reddit.png");
|
watermark.read("./assets/images/reddit.png");
|
||||||
text_image.textGravity(Magick::WestGravity);
|
text_image.textGravity(Magick::WestGravity);
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Resize(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
bool stretch = obj.Has("stretch")
|
bool stretch = obj.Has("stretch")
|
||||||
? obj.Get("stretch").As<Napi::Boolean>().Value()
|
? obj.Get("stretch").As<Napi::Boolean>().Value()
|
||||||
: false;
|
: false;
|
||||||
|
@ -26,7 +26,7 @@ Napi::Value Resize(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> blurred;
|
list<Image> blurred;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for (Image &image : coalesced) {
|
for (Image &image : coalesced) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Reverse(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
bool soos =
|
bool soos =
|
||||||
obj.Has("soos") ? obj.Get("soos").As<Napi::Boolean>().Value() : false;
|
obj.Has("soos") ? obj.Get("soos").As<Napi::Boolean>().Value() : false;
|
||||||
int delay =
|
int delay =
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Reverse(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
if (soos) {
|
if (soos) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Scott(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -22,7 +22,7 @@ Napi::Value Scott(const Napi::CallbackInfo &info) {
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image watermark;
|
Image watermark;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
watermark.read("./assets/images/scott.png");
|
watermark.read("./assets/images/scott.png");
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
bool slow =
|
bool slow =
|
||||||
obj.Has("slow") ? obj.Get("slow").As<Napi::Boolean>().Value() : false;
|
obj.Has("slow") ? obj.Get("slow").As<Napi::Boolean>().Value() : false;
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
|
@ -23,7 +23,7 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
|
||||||
Blob blob;
|
Blob blob;
|
||||||
|
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
|
|
||||||
// if passed a delay, use that. otherwise use the average frame delay.
|
// if passed a delay, use that. otherwise use the average frame delay.
|
||||||
if (delay == 0) {
|
if (delay == 0) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Spin(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Spin(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
if (type != "gif") {
|
if (type != "gif") {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Swirl(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Swirl(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for (Image &image : coalesced) {
|
for (Image &image : coalesced) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Tile(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Tile(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for (Image &image : coalesced) {
|
for (Image &image : coalesced) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Trump(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -22,7 +22,7 @@ Napi::Value Trump(const Napi::CallbackInfo &info) {
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image watermark;
|
Image watermark;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
watermark.read("./assets/images/trump.png");
|
watermark.read("./assets/images/trump.png");
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -44,7 +44,7 @@ Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
Image firstImage = coalesced.front();
|
Image firstImage = coalesced.front();
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Wall(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -21,7 +21,7 @@ Napi::Value Wall(const Napi::CallbackInfo &info) {
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
for (Image &image : coalesced) {
|
for (Image &image : coalesced) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string water = obj.Get("water").As<Napi::String>().Utf8Value();
|
string water = obj.Get("water").As<Napi::String>().Utf8Value();
|
||||||
int gravity = obj.Get("gravity").As<Napi::Number>().Int32Value();
|
int gravity = obj.Get("gravity").As<Napi::Number>().Int32Value();
|
||||||
bool resize = obj.Has("resize")
|
bool resize = obj.Has("resize")
|
||||||
|
@ -32,7 +32,7 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image watermark;
|
Image watermark;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
watermark.read(water);
|
watermark.read(water);
|
||||||
if (resize && append) {
|
if (resize && append) {
|
||||||
string query(to_string(frames.front().baseColumns()) + "x");
|
string query(to_string(frames.front().baseColumns()) + "x");
|
||||||
|
|
|
@ -11,7 +11,7 @@ Napi::Value Wdt(const Napi::CallbackInfo &info) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Napi::Object obj = info[0].As<Napi::Object>();
|
Napi::Object obj = info[0].As<Napi::Object>();
|
||||||
string path = obj.Get("path").As<Napi::String>().Utf8Value();
|
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||||
int delay =
|
int delay =
|
||||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||||
|
@ -22,7 +22,7 @@ Napi::Value Wdt(const Napi::CallbackInfo &info) {
|
||||||
list<Image> coalesced;
|
list<Image> coalesced;
|
||||||
list<Image> mid;
|
list<Image> mid;
|
||||||
Image watermark;
|
Image watermark;
|
||||||
readImages(&frames, path);
|
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||||
watermark.read("./assets/images/whodidthis.png");
|
watermark.read("./assets/images/whodidthis.png");
|
||||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,36 @@
|
||||||
const magick = require("../build/Release/image.node");
|
const magick = require("../build/Release/image.node");
|
||||||
const { isMainThread, parentPort, workerData } = require("worker_threads");
|
const { isMainThread, parentPort, workerData } = require("worker_threads");
|
||||||
|
const fetch = require("node-fetch");
|
||||||
|
|
||||||
exports.run = object => {
|
exports.run = object => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// If the image has a path, it must also have a type
|
// If the image has a path, it must also have a type
|
||||||
|
let promise = new Promise((resolveTest) => { resolveTest(); }); // no-op
|
||||||
if (object.path) {
|
if (object.path) {
|
||||||
if (object.type !== "image/gif" && object.onlyGIF) resolve({
|
if (object.type !== "image/gif" && object.onlyGIF) resolve({
|
||||||
buffer: Buffer.alloc(0),
|
buffer: Buffer.alloc(0),
|
||||||
fileExtension: "nogif"
|
fileExtension: "nogif"
|
||||||
});
|
});
|
||||||
|
promise = fetch(object.path).then(res => res.buffer());
|
||||||
}
|
}
|
||||||
// Convert from a MIME type (e.g. "image/png") to something ImageMagick understands (e.g. "png").
|
// Convert from a MIME type (e.g. "image/png") to something ImageMagick understands (e.g. "png").
|
||||||
// Don't set `type` directly on the object we are passed as it will be read afterwards.
|
// Don't set `type` directly on the object we are passed as it will be read afterwards.
|
||||||
// If no image type is given (say, the command generates its own image), make it a PNG.
|
// If no image type is given (say, the command generates its own image), make it a PNG.
|
||||||
const fileExtension = object.type ? object.type.split("/")[1] : "png";
|
const fileExtension = object.type ? object.type.split("/")[1] : "png";
|
||||||
const objectWithFixedType = Object.assign({}, object, {type: fileExtension});
|
promise.then(buf => {
|
||||||
try {
|
object.data = buf;
|
||||||
const result = magick[object.cmd](objectWithFixedType);
|
const objectWithFixedType = Object.assign({}, object, {type: fileExtension});
|
||||||
const returnObject = {
|
try {
|
||||||
buffer: result.data,
|
const result = magick[object.cmd](objectWithFixedType);
|
||||||
fileExtension: result.type
|
const returnObject = {
|
||||||
};
|
buffer: result.data,
|
||||||
resolve(returnObject);
|
fileExtension: result.type
|
||||||
} catch (e) {
|
};
|
||||||
reject(e);
|
resolve(returnObject);
|
||||||
}
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue