mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
|
|
const sharp = require('../../index');
|
|
const fixtures = require('../fixtures');
|
|
|
|
describe('Interpolators and kernels', function () {
|
|
describe('Reducers', function () {
|
|
[
|
|
sharp.kernel.cubic,
|
|
sharp.kernel.lanczos2,
|
|
sharp.kernel.lanczos3
|
|
].forEach(function (kernel) {
|
|
it(kernel, function (done) {
|
|
sharp(fixtures.inputJpg)
|
|
.resize(320, null, { kernel: kernel })
|
|
.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('Enlargers', function () {
|
|
[
|
|
sharp.interpolator.nearest,
|
|
sharp.interpolator.bilinear,
|
|
sharp.interpolator.bicubic,
|
|
sharp.interpolator.nohalo,
|
|
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);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
it('unknown kernel throws', function () {
|
|
assert.throws(function () {
|
|
sharp().resize(null, null, { kernel: 'unknown' });
|
|
});
|
|
});
|
|
|
|
it('unknown interpolator throws', function () {
|
|
assert.throws(function () {
|
|
sharp().resize(null, null, { interpolator: 'unknown' });
|
|
});
|
|
});
|
|
});
|