Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[notready] Init before resize #585

Merged
merged 5 commits into from
Jan 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"url": "http://github.com/mapnik/node-mapnik",
"homepage": "http://mapnik.org",
"author": "Dane Springmeyer <dane@mapbox.com> (mapnik.org)",
"version": "3.4.15",
"version": "3.4.15-init",
"main": "./lib/mapnik.js",
"binary": {
"module_name": "mapnik",
Expand Down
4 changes: 2 additions & 2 deletions src/mapnik_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ void Image::EIO_Resize(uv_work_t* req)
closure->im2 = std::make_shared<mapnik::image_any>(closure->size_x,
closure->size_y,
closure->im1->this_->get_dtype(),
false,
true,
true,
false);
closure->im2->set_offset(offset);
Expand Down Expand Up @@ -2025,7 +2025,7 @@ v8::Local<v8::Value> Image::_resizeSync(Nan::NAN_METHOD_ARGS_TYPE info)
std::shared_ptr<mapnik::image_any> image_ptr = std::make_shared<mapnik::image_any>(width,
height,
im->this_->get_dtype(),
false,
true,
true,
false);
image_ptr->set_offset(offset);
Expand Down
33 changes: 33 additions & 0 deletions test/image.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1505,4 +1505,37 @@ describe('mapnik.Image ', function() {
assert.throws(function() { var im = new mapnik.Image.fromBufferSync(2, 2, b, {'painted':null}); });
});

it('resizes consistently', function(done) {
var data = require('fs').readFileSync(__dirname + '/support/a.png');
var image = mapnik.Image.fromBytesSync(data);
image.premultiplySync();
image.resize(64, 64, function(err, control) {
if (err) throw err;
var remaining = 100;
for (var i = 0; i < 100; i++) (function() {
mapnik.Image.fromBytes(data, function(err, im) {
if (err) throw err;
im.premultiply(function(err, im) {
if (err) throw err;
im.resize(64,64,{}, function(err,resized) {
if (err) throw err;
assert.equal(control.compare(resized, {}), 0);
if (!--remaining) done();
});
});
});
})();
});
});

it('resizes consistently (sync)', function(done) {
var data = require('fs').readFileSync(__dirname + '/support/a.png');
var image = mapnik.Image.fromBytesSync(data);
image.premultiplySync();
var control = image.resizeSync(64, 64);
for (var i = 0; i < 100; i++) {
assert.equal(control.compare(image.resizeSync(64, 64), {}), 0);
}
done();
});
});