Improve perf/accuracy of nearest neighbour integral upsample

This commit is contained in:
Lovell Fuller
2017-04-30 20:54:48 +01:00
parent 52bea15ad7
commit 4d1a1694cd
3 changed files with 67 additions and 18 deletions

View File

@@ -35,17 +35,54 @@ describe('Interpolators and kernels', function () {
sharp.interpolator.locallyBoundedBicubic,
sharp.interpolator.vertexSplitQuadraticBasisSpline
].forEach(function (interpolator) {
it(interpolator, function (done) {
sharp(fixtures.inputJpg)
.resize(320, null, { interpolator: interpolator })
.toBuffer(function (err, data, info) {
if (err) throw err;
assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width);
fixtures.assertSimilar(fixtures.inputJpg, data, done);
});
describe(interpolator, function () {
it('x and y', function (done) {
sharp(fixtures.inputTiff8BitDepth)
.resize(200, 200, { interpolator: interpolator })
.png()
.toBuffer(function (err, data, info) {
if (err) throw err;
assert.strictEqual(200, info.width);
assert.strictEqual(200, info.height);
done();
});
});
it('x only', function (done) {
sharp(fixtures.inputTiff8BitDepth)
.resize(200, 21, { interpolator: interpolator })
.png()
.toBuffer(function (err, data, info) {
if (err) throw err;
assert.strictEqual(200, info.width);
assert.strictEqual(21, info.height);
done();
});
});
it('y only', function (done) {
sharp(fixtures.inputTiff8BitDepth)
.resize(21, 200, { interpolator: interpolator })
.png()
.toBuffer(function (err, data, info) {
if (err) throw err;
assert.strictEqual(21, info.width);
assert.strictEqual(200, info.height);
done();
});
});
});
});
it('nearest with integral factor', function (done) {
sharp(fixtures.inputTiff8BitDepth)
.resize(210, 210, { interpolator: 'nearest' })
.png()
.toBuffer(function (err, data, info) {
if (err) throw err;
assert.strictEqual(210, info.width);
assert.strictEqual(210, info.height);
done();
});
});
});
it('unknown kernel throws', function () {