Expose WebP smartDeblock output option

This commit is contained in:
Lovell Fuller
2024-10-29 14:41:58 +00:00
parent 3154af776e
commit 8afec170ed
8 changed files with 38 additions and 1 deletions

View File

@@ -102,6 +102,29 @@ describe('WebP', function () {
});
});
it('can produce a different file size using smartDeblock', () =>
sharp(fixtures.inputPngOverlayLayer0)
.resize(320, 240)
.webp({ quality: 30, smartDeblock: false })
.toBuffer()
.then(withoutSmartDeblock =>
sharp(fixtures.inputPngOverlayLayer0)
.resize(320, 240)
.webp({ quality: 30, smartDeblock: true })
.toBuffer()
.then(withSmartDeblock => {
assert.strictEqual(true, withSmartDeblock.length !== withoutSmartDeblock.length);
})
)
);
it('invalid smartDeblock throws', () => {
assert.throws(
() => sharp().webp({ smartDeblock: 1 }),
/Expected boolean for webpSmartDeblock but received 1 of type number/
);
});
it('should produce a different file size with specific preset', () =>
sharp(fixtures.inputJpg)
.resize(320, 240)