A couple of image code tweaks

This commit is contained in:
Essem 2022-06-07 22:04:39 -05:00
parent 274f11bb76
commit a3f2bd4c7e
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
3 changed files with 6 additions and 7 deletions

View file

@ -36,8 +36,9 @@ Napi::Value Deepfry(const Napi::CallbackInfo &info) {
void *buf;
size_t length;
final.write_to_buffer(("." + type).c_str(), &buf, &length,
VImage::option()->set("dither", 0));
final.write_to_buffer(
("." + type).c_str(), &buf, &length,
type == "gif" ? VImage::option()->set("dither", 0) : 0);
vips_thread_shutdown();

View file

@ -39,8 +39,9 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info) {
void *buf;
size_t length;
final.write_to_buffer(("." + type).c_str(), &buf, &length,
VImage::option()->set("dither", 0));
final.write_to_buffer(
("." + type).c_str(), &buf, &length,
type == "gif" ? VImage::option()->set("dither", 0) : 0);
vips_thread_shutdown();

View file

@ -14,8 +14,6 @@ Napi::Value Magik(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;
@ -45,7 +43,6 @@ Napi::Value Magik(const Napi::CallbackInfo &info) {
for (Image &image : blurred) {
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
image.quantize();
if (delay != 0) image.animationDelay(delay);
}
}