mirror of
https://github.com/lovell/sharp.git
synced 2026-02-04 13:46:19 +01:00
Add AVIF/HEIF 'tune' option to control quality metrics #4227
This commit is contained in:
@@ -181,4 +181,16 @@ describe('AVIF', () => {
|
||||
/Expected 8, 10 or 12 for bitdepth but received 11 of type number/
|
||||
)
|
||||
);
|
||||
|
||||
it('Different tune options result in different file sizes', async () => {
|
||||
const ssim = await sharp(inputJpg)
|
||||
.resize(32)
|
||||
.avif({ tune: 'ssim', effort: 0 })
|
||||
.toBuffer();
|
||||
const iq = await sharp(inputJpg)
|
||||
.resize(32)
|
||||
.avif({ tune: 'iq', effort: 0 })
|
||||
.toBuffer();
|
||||
assert(ssim.length < iq.length);
|
||||
})
|
||||
});
|
||||
|
||||
@@ -96,4 +96,14 @@ describe('HEIF', () => {
|
||||
sharp().heif({ compression: 'av1', bitdepth: 11 });
|
||||
}, /Error: Expected 8, 10 or 12 for bitdepth but received 11 of type number/);
|
||||
});
|
||||
it('valid tune does not throw an error', () => {
|
||||
assert.doesNotThrow(() => {
|
||||
sharp().heif({ compression: 'hevc', tune: 'psnr' });
|
||||
});
|
||||
});
|
||||
it('invalid tune should throw an error', () => {
|
||||
assert.throws(() => {
|
||||
sharp().heif({ compression: 'hevc', tune: 'fail' });
|
||||
}, /Error: Expected one of: psnr, ssim, iq for tune but received fail of type string/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user