diff --git a/src/mapnik_image.cpp b/src/mapnik_image.cpp index d79d666515..54fc146f31 100644 --- a/src/mapnik_image.cpp +++ b/src/mapnik_image.cpp @@ -106,14 +106,13 @@ Image::Image(Napi::CallbackInfo const& info) return; } - if (info.Length() == 1 && info[0].IsBuffer()) + if (info.Length() == 5 && info[0].IsBuffer() && info[1].IsNumber() && info[2].IsNumber() && info[3].IsBoolean() && info[4].IsBoolean()) { auto buf = info[0].As>(); - auto obj = info[0].As(); - bool premultiplied = obj.Get("premultiplied").As(); - bool painted = obj.Get("painted").As(); - int width = obj.Get("width").As().Int32Value(); - int height = obj.Get("height").As().Int32Value(); + int width = info[1].As().Int32Value(); + int height = info[2].As().Int32Value(); + bool premultiplied = info[3].As(); + bool painted = info[4].As(); mapnik::image_rgba8 im_wrapper(width, height, buf.Data(), premultiplied, painted); image_ = std::make_shared(im_wrapper); buf_ref_ = Napi::Persistent(buf); diff --git a/src/mapnik_image_from_bytes.cpp b/src/mapnik_image_from_bytes.cpp index bf4eb52473..cb0365bec4 100644 --- a/src/mapnik_image_from_bytes.cpp +++ b/src/mapnik_image_from_bytes.cpp @@ -335,11 +335,11 @@ Napi::Value Image::fromBufferSync(Napi::CallbackInfo const& info) try { - obj.Set("width", width); - obj.Set("height", height); - obj.Set("premultiplied", premultiplied); - obj.Set("painted", painted); - Napi::Object image_obj = constructor.New({obj}); + Napi::Object image_obj = constructor.New({obj, + Napi::Number::New(env, width), + Napi::Number::New(env, height), + Napi::Boolean::New(env, premultiplied), + Napi::Boolean::New(env, painted)}); return scope.Escape(image_obj); } catch (std::exception const& ex)