torque/test/support/image.js
Raul Ochoa 49b093d3de Adds mapnik and qunit dependencies for acceptance tests
Basic test with canvas
abstracts mapnik comparison in image test helper
Ignore temporal images `results` directory
2015-03-04 17:23:08 +01:00

20 lines
497 B
JavaScript

var mapnik = require('mapnik');
function compare(buffer, fixtureRelPath) {
save(__dirname + '/../results/' + fixtureRelPath, buffer);
var img = new mapnik.Image.fromBytesSync(buffer);
var reference = new mapnik.Image.openSync(__dirname + '/../fixtures/image/' + fixtureRelPath);
return img.compare(reference);
}
function save(path, buffer) {
var img = new mapnik.Image.fromBytesSync(buffer);
img.save(path);
}
module.exports = {
compare: compare,
save: save
};