mirror of
https://github.com/lovell/sharp.git
synced 2026-02-04 05:36:18 +01:00
Add nearest neighbour interpolation
Suitable for image enlargement
This commit is contained in:
@@ -185,6 +185,18 @@ async.series({
|
||||
}
|
||||
});
|
||||
}
|
||||
}).add("sharp-file-buffer-nearest-neighbour", {
|
||||
defer: true,
|
||||
fn: function(deferred) {
|
||||
sharp(inputJpg).resize(width, height).interpolateWith(sharp.interpolator.nearest).toBuffer(function(err, buffer) {
|
||||
if (err) {
|
||||
throw err;
|
||||
} else {
|
||||
assert.notStrictEqual(null, buffer);
|
||||
deferred.resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
}).add("sharp-file-buffer-bicubic", {
|
||||
defer: true,
|
||||
fn: function(deferred) {
|
||||
|
||||
@@ -247,6 +247,16 @@ async.series([
|
||||
done();
|
||||
});
|
||||
},
|
||||
// Interpolation: nearest neighbour
|
||||
function(done) {
|
||||
sharp(inputJpg).resize(320, 240).interpolateWith(sharp.interpolator.nearest).toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
done();
|
||||
});
|
||||
},
|
||||
// Interpolation: bilinear
|
||||
function(done) {
|
||||
sharp(inputJpg).resize(320, 240).interpolateWith(sharp.interpolator.bilinear).toBuffer(function(err, data, info) {
|
||||
|
||||
Reference in New Issue
Block a user