Remove delay parameter, change argument handling, make help command show proper flag types
This commit is contained in:
parent
28f0245652
commit
6b34cb9d9e
63 changed files with 82 additions and 219 deletions
|
@ -15,8 +15,6 @@ Napi::Value Blur(const Napi::CallbackInfo &info) {
|
|||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
bool sharp = obj.Get("sharp").As<Napi::Boolean>().Value();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -31,8 +29,6 @@ Napi::Value Blur(const Napi::CallbackInfo &info) {
|
|||
VImage out = sharp ? in.sharpen(VImage::option()->set("sigma", 3))
|
||||
: in.gaussblur(15);
|
||||
|
||||
if (delay) out.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||
|
|
|
@ -13,8 +13,6 @@ Napi::Value Caption(const Napi::CallbackInfo &info) {
|
|||
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
|
||||
string font = obj.Get("font").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;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -59,7 +57,6 @@ Napi::Value Caption(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height + captionImage.height());
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -15,8 +15,6 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
|||
bool top = obj.Get("top").As<Napi::Boolean>().Value();
|
||||
string font = obj.Get("font").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;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -63,7 +61,6 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height + captionImage.height());
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -14,8 +14,6 @@ Napi::Value Circle(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();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
Blob blob;
|
||||
|
||||
|
@ -43,7 +41,6 @@ Napi::Value Circle(const Napi::CallbackInfo &info) {
|
|||
for (Image &image : blurred) {
|
||||
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||
image.quantize();
|
||||
if (delay != 0) image.animationDelay(delay);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ Napi::Value Colors(const Napi::CallbackInfo &info) {
|
|||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string color = obj.Get("color").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;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -35,7 +33,6 @@ Napi::Value Colors(const Napi::CallbackInfo &info) {
|
|||
} else if (color == "sepia") {
|
||||
out = in.flatten().recomb(sepia);
|
||||
}
|
||||
if (delay) out.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -12,8 +12,6 @@ Napi::Value Crop(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();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -45,7 +43,6 @@ Napi::Value Crop(const Napi::CallbackInfo &info) {
|
|||
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, finalHeight);
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -12,8 +12,6 @@ Napi::Value Deepfry(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();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
|
@ -34,11 +32,7 @@ Napi::Value Deepfry(const Napi::CallbackInfo &info) {
|
|||
VImage::option()->set("Q", 1)->set("strip", true));
|
||||
VImage final = VImage::new_from_buffer(jpgBuf, jpgLength, "");
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height);
|
||||
if (delay) {
|
||||
final.set("delay", delay);
|
||||
} else if (type == "gif") {
|
||||
final.set("delay", fried.get_array_int("delay"));
|
||||
}
|
||||
final.set("delay", fried.get_array_int("delay"));
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -14,8 +14,6 @@ Napi::Value Flag(const Napi::CallbackInfo &info) {
|
|||
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;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -53,7 +51,6 @@ Napi::Value Flag(const Napi::CallbackInfo &info) {
|
|||
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height);
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -14,8 +14,6 @@ Napi::Value Flip(const Napi::CallbackInfo &info) {
|
|||
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.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -44,8 +42,6 @@ Napi::Value Flip(const Napi::CallbackInfo &info) {
|
|||
out = in.flip(VIPS_DIRECTION_VERTICAL);
|
||||
}
|
||||
|
||||
if (delay) out.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||
|
|
|
@ -14,8 +14,6 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
|
|||
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.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
int frame = obj.Has("frame")
|
||||
? obj.Get("frame").As<Napi::Number>().Int32Value()
|
||||
: -1;
|
||||
|
@ -67,8 +65,6 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
|
|||
out.set(VIPS_META_PAGE_HEIGHT, page_height);
|
||||
out.set("loop", loop ? 0 : 1);
|
||||
|
||||
if (delay) out.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||
|
|
|
@ -13,8 +13,6 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
|||
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;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -46,7 +44,6 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, 675);
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -12,8 +12,6 @@ Napi::Value Invert(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();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -28,8 +26,6 @@ Napi::Value Invert(const Napi::CallbackInfo &info) {
|
|||
VImage inverted = noAlpha.invert();
|
||||
VImage out = inverted.bandjoin(in.extract_band(3));
|
||||
|
||||
if (delay) out.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||
|
|
|
@ -15,8 +15,6 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
|||
? obj.Get("quality").As<Napi::Number>().Int32Value()
|
||||
: 0;
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
Napi::Object result = Napi::Object::New(env);
|
||||
|
||||
|
@ -37,11 +35,7 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
|||
VImage::option()->set("Q", quality)->set("strip", true));
|
||||
VImage final = VImage::new_from_buffer(jpgBuf, jpgLength, "");
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height);
|
||||
if (delay) {
|
||||
final.set("delay", delay);
|
||||
} else if (type == "gif") {
|
||||
final.set("delay", in.get_array_int("delay"));
|
||||
}
|
||||
final.set("delay", in.get_array_int("delay"));
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -15,8 +15,6 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
string bottom = obj.Get("bottom").As<Napi::String>().Utf8Value();
|
||||
string font = obj.Get("font").As<Napi::String>().Utf8Value();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -125,7 +123,6 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height);
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -17,8 +17,6 @@ Napi::Value Mirror(const Napi::CallbackInfo &info) {
|
|||
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.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -67,8 +65,6 @@ Napi::Value Mirror(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
}
|
||||
|
||||
if (delay) out.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
out.write_to_buffer(("." + type).c_str(), &buf, &length);
|
||||
|
|
|
@ -15,8 +15,6 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
|||
string bottom_text = obj.Get("bottom").As<Napi::String>().Utf8Value();
|
||||
string font = obj.Get("font").As<Napi::String>().Utf8Value();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -103,7 +101,6 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
|||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1))
|
||||
.extract_band(0, VImage::option()->set("n", 3));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, height);
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -13,8 +13,6 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
|
|||
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;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -56,7 +54,6 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height + watermark.height());
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -17,8 +17,6 @@ Napi::Value Resize(const Napi::CallbackInfo &info) {
|
|||
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.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -47,7 +45,6 @@ Napi::Value Resize(const Napi::CallbackInfo &info) {
|
|||
finalHeight = page_height;
|
||||
}
|
||||
out.set(VIPS_META_PAGE_HEIGHT, finalHeight);
|
||||
if (delay) out.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -15,8 +15,6 @@ Napi::Value Scott(const Napi::CallbackInfo &info) {
|
|||
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;
|
||||
|
||||
Blob blob;
|
||||
|
||||
|
@ -46,7 +44,7 @@ Napi::Value Scott(const Napi::CallbackInfo &info) {
|
|||
watermark_new.composite(image, Geometry("-110+83"),
|
||||
Magick::OverCompositeOp);
|
||||
watermark_new.magick(type);
|
||||
watermark_new.animationDelay(delay == 0 ? image.animationDelay() : delay);
|
||||
watermark_new.animationDelay(image.animationDelay());
|
||||
mid.push_back(watermark_new);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ Napi::Value Snapchat(const Napi::CallbackInfo &info) {
|
|||
float pos =
|
||||
obj.Has("pos") ? obj.Get("pos").As<Napi::Number>().FloatValue() : 0.5;
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -64,7 +62,6 @@ Napi::Value Snapchat(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height);
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
107
natives/speed.cc
107
natives/speed.cc
|
@ -51,8 +51,6 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
|
|||
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.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
int speed =
|
||||
obj.Has("speed") ? obj.Get("speed").As<Napi::Number>().Int32Value() : 2;
|
||||
|
||||
|
@ -62,94 +60,51 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
|
|||
|
||||
char *match = (char *)"\x00\x21\xF9\x04";
|
||||
|
||||
// if passed a delay, use that. otherwise iterate over every frame.
|
||||
if (delay == 0) {
|
||||
vector<uint16_t> old_delays;
|
||||
bool removeFrames = false;
|
||||
char *lastPos;
|
||||
vector<uint16_t> old_delays;
|
||||
bool removeFrames = false;
|
||||
char *lastPos;
|
||||
|
||||
int amount = 0;
|
||||
int amount = 0;
|
||||
|
||||
lastPos = (char *)memchr(fileData, '\x00', data.Length());
|
||||
while (lastPos != NULL) {
|
||||
if (memcmp(lastPos, match, 4) != 0) {
|
||||
lastPos = (char *)memchr(lastPos + 1, '\x00',
|
||||
(data.Length() - (lastPos - fileData)) - 1);
|
||||
continue;
|
||||
}
|
||||
++amount;
|
||||
uint16_t old_delay;
|
||||
memcpy(&old_delay, lastPos + 5, 2);
|
||||
old_delays.push_back(old_delay);
|
||||
lastPos = (char *)memchr(fileData, '\x00', data.Length());
|
||||
while (lastPos != NULL) {
|
||||
if (memcmp(lastPos, match, 4) != 0) {
|
||||
lastPos = (char *)memchr(lastPos + 1, '\x00',
|
||||
(data.Length() - (lastPos - fileData)) - 1);
|
||||
continue;
|
||||
}
|
||||
++amount;
|
||||
uint16_t old_delay;
|
||||
memcpy(&old_delay, lastPos + 5, 2);
|
||||
old_delays.push_back(old_delay);
|
||||
lastPos = (char *)memchr(lastPos + 1, '\x00',
|
||||
(data.Length() - (lastPos - fileData)) - 1);
|
||||
}
|
||||
|
||||
int currentFrame = 0;
|
||||
lastPos = (char *)memchr(fileData, '\x00', data.Length());
|
||||
while (lastPos != NULL) {
|
||||
if (memcmp(lastPos, match, 4) != 0) {
|
||||
lastPos = (char *)memchr(lastPos + 1, '\x00',
|
||||
(data.Length() - (lastPos - fileData)) - 1);
|
||||
continue;
|
||||
}
|
||||
uint16_t new_delay = slow ? old_delays[currentFrame] * speed
|
||||
: old_delays[currentFrame] / speed;
|
||||
if (!slow && new_delay <= 1) {
|
||||
removeFrames = true;
|
||||
break;
|
||||
}
|
||||
memset16(lastPos + 5, new_delay, 1);
|
||||
int currentFrame = 0;
|
||||
lastPos = (char *)memchr(fileData, '\x00', data.Length());
|
||||
while (lastPos != NULL) {
|
||||
if (memcmp(lastPos, match, 4) != 0) {
|
||||
lastPos = (char *)memchr(lastPos + 1, '\x00',
|
||||
(data.Length() - (lastPos - fileData)) - 1);
|
||||
++currentFrame;
|
||||
continue;
|
||||
}
|
||||
|
||||
result.Set("data",
|
||||
Napi::Buffer<char>::Copy(env, fileData, data.Length()));
|
||||
|
||||
if (removeFrames) vipsRemove(&env, &result, data, speed);
|
||||
} else {
|
||||
char *lastPos;
|
||||
|
||||
bool removeFrames = false;
|
||||
|
||||
lastPos = (char *)memchr(fileData, '\x00', data.Length());
|
||||
while (lastPos != NULL) {
|
||||
if (memcmp(lastPos, match, 4) != 0) {
|
||||
lastPos = (char *)memchr(lastPos + 1, '\x00',
|
||||
(data.Length() - (lastPos - fileData)) - 1);
|
||||
continue;
|
||||
}
|
||||
uint16_t old_delay;
|
||||
memcpy(&old_delay, lastPos + 5, 2);
|
||||
int new_delay = slow ? delay * speed : delay / speed;
|
||||
if (!slow && new_delay <= 1) {
|
||||
removeFrames = true;
|
||||
}
|
||||
uint16_t new_delay = slow ? old_delays[currentFrame] * speed
|
||||
: old_delays[currentFrame] / speed;
|
||||
if (!slow && new_delay <= 1) {
|
||||
removeFrames = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (removeFrames) {
|
||||
vipsRemove(&env, &result, data, speed);
|
||||
} else {
|
||||
while (lastPos != NULL) {
|
||||
if (memcmp(lastPos, match, 4) != 0) {
|
||||
lastPos =
|
||||
(char *)memchr(lastPos + 1, '\x00',
|
||||
memset16(lastPos + 5, new_delay, 1);
|
||||
lastPos = (char *)memchr(lastPos + 1, '\x00',
|
||||
(data.Length() - (lastPos - fileData)) - 1);
|
||||
continue;
|
||||
}
|
||||
uint16_t old_delay;
|
||||
memcpy(&old_delay, lastPos + 5, 2);
|
||||
int new_delay = slow ? delay * speed : delay / speed;
|
||||
memset16(lastPos + 5, new_delay, 1);
|
||||
lastPos = (char *)memchr(lastPos + 1, '\x00',
|
||||
(data.Length() - (lastPos - fileData)) - 1);
|
||||
}
|
||||
}
|
||||
++currentFrame;
|
||||
}
|
||||
|
||||
result.Set("data", Napi::Buffer<char>::Copy(env, fileData, data.Length()));
|
||||
|
||||
if (removeFrames) vipsRemove(&env, &result, data, speed);
|
||||
|
||||
result.Set("type", type);
|
||||
return result;
|
||||
} catch (std::exception const &err) {
|
||||
|
|
|
@ -14,8 +14,6 @@ Napi::Value Tile(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();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
Blob blob;
|
||||
|
||||
|
@ -48,7 +46,7 @@ Napi::Value Tile(const Napi::CallbackInfo &info) {
|
|||
appendImages(&frame, montage.begin(), montage.end(), true);
|
||||
frame.repage();
|
||||
frame.scale(Geometry("800x800>"));
|
||||
frame.animationDelay(delay == 0 ? image.animationDelay() : delay);
|
||||
frame.animationDelay(image.animationDelay());
|
||||
mid.push_back(frame);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
|||
? obj.Get("tolerance").As<Napi::Number>().FloatValue()
|
||||
: 0.5;
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
VOption *options = VImage::option();
|
||||
|
||||
|
@ -44,7 +42,6 @@ Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height - top);
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -14,8 +14,6 @@ Napi::Value Wall(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();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
||||
Blob blob;
|
||||
|
||||
|
@ -51,7 +49,6 @@ Napi::Value Wall(const Napi::CallbackInfo &info) {
|
|||
for (Image &image : mid) {
|
||||
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||
image.quantize();
|
||||
if (delay != 0) image.animationDelay(delay);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
|
|||
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;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -145,7 +143,6 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height + addedHeight);
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -15,8 +15,6 @@ Napi::Value Wdt(const Napi::CallbackInfo &info) {
|
|||
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;
|
||||
|
||||
Blob blob;
|
||||
|
||||
|
@ -40,7 +38,7 @@ Napi::Value Wdt(const Napi::CallbackInfo &info) {
|
|||
watermark_new.composite(image, Magick::CenterGravity,
|
||||
Magick::OverCompositeOp);
|
||||
watermark_new.magick(type);
|
||||
watermark_new.animationDelay(delay == 0 ? image.animationDelay() : delay);
|
||||
watermark_new.animationDelay(image.animationDelay());
|
||||
mid.push_back(watermark_new);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ Napi::Value Whisper(const Napi::CallbackInfo &info) {
|
|||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string caption = obj.Get("caption").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;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -78,7 +76,6 @@ Napi::Value Whisper(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, page_height);
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
|
@ -13,8 +13,6 @@ Napi::Value Zamn(const Napi::CallbackInfo &info) {
|
|||
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;
|
||||
|
||||
VOption *options = VImage::option()->set("access", "sequential");
|
||||
|
||||
|
@ -44,7 +42,6 @@ Napi::Value Zamn(const Napi::CallbackInfo &info) {
|
|||
}
|
||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||
final.set(VIPS_META_PAGE_HEIGHT, 516);
|
||||
if (delay) final.set("delay", delay);
|
||||
|
||||
void *buf;
|
||||
size_t length;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue