mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Allow sharpen options to be provided as an Object
Also exposes x1, y2, y3 parameters #2561 #2935
This commit is contained in:
@@ -45,6 +45,22 @@ describe('Sharpen', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('sigma=3.5, m1=2, m2=4', (done) => {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.sharpen({ sigma: 3.5, m1: 2, m2: 4 })
|
||||
.toBuffer()
|
||||
.then(data => fixtures.assertSimilar(fixtures.expected('sharpen-5-2-4.jpg'), data, done));
|
||||
});
|
||||
|
||||
it('sigma=3.5, m1=2, m2=4, x1=2, y2=5, y3=25', (done) => {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.sharpen({ sigma: 3.5, m1: 2, m2: 4, x1: 2, y2: 5, y3: 25 })
|
||||
.toBuffer()
|
||||
.then(data => fixtures.assertSimilar(fixtures.expected('sharpen-5-2-4.jpg'), data, done));
|
||||
});
|
||||
|
||||
if (!process.env.SHARP_TEST_WITHOUT_CACHE) {
|
||||
it('specific radius/levels with alpha channel', function (done) {
|
||||
sharp(fixtures.inputPngWithTransparency)
|
||||
@@ -92,6 +108,36 @@ describe('Sharpen', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('invalid options.sigma', () => assert.throws(
|
||||
() => sharp().sharpen({ sigma: -1 }),
|
||||
/Expected number between 0\.01 and 10000 for options\.sigma but received -1 of type number/
|
||||
));
|
||||
|
||||
it('invalid options.m1', () => assert.throws(
|
||||
() => sharp().sharpen({ sigma: 1, m1: -1 }),
|
||||
/Expected number between 0 and 10000 for options\.m1 but received -1 of type number/
|
||||
));
|
||||
|
||||
it('invalid options.m2', () => assert.throws(
|
||||
() => sharp().sharpen({ sigma: 1, m2: -1 }),
|
||||
/Expected number between 0 and 10000 for options\.m2 but received -1 of type number/
|
||||
));
|
||||
|
||||
it('invalid options.x1', () => assert.throws(
|
||||
() => sharp().sharpen({ sigma: 1, x1: -1 }),
|
||||
/Expected number between 0 and 10000 for options\.x1 but received -1 of type number/
|
||||
));
|
||||
|
||||
it('invalid options.y2', () => assert.throws(
|
||||
() => sharp().sharpen({ sigma: 1, y2: -1 }),
|
||||
/Expected number between 0 and 10000 for options\.y2 but received -1 of type number/
|
||||
));
|
||||
|
||||
it('invalid options.y3', () => assert.throws(
|
||||
() => sharp().sharpen({ sigma: 1, y3: -1 }),
|
||||
/Expected number between 0 and 10000 for options\.y3 but received -1 of type number/
|
||||
));
|
||||
|
||||
it('sharpened image is larger than non-sharpened', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
|
||||
Reference in New Issue
Block a user