mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Improve perf/accuracy of nearest neighbour integral upsample
This commit is contained in:
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user