Ensure AVIF output is always 8-bit #3358

This commit is contained in:
Lovell Fuller
2022-09-14 13:33:47 +01:00
parent fbd4970b57
commit 28b87db760
3 changed files with 31 additions and 2 deletions

View File

@@ -103,4 +103,28 @@ describe('AVIF', () => {
width: 10
});
});
it('should cast to uchar', async () => {
const data = await sharp(inputJpg)
.resize(32)
.sharpen()
.avif({ effort: 0 })
.toBuffer();
const { size, ...metadata } = await sharp(data)
.metadata();
assert.deepStrictEqual(metadata, {
channels: 3,
compression: 'av1',
depth: 'uchar',
format: 'heif',
hasAlpha: false,
hasProfile: false,
height: 26,
isProgressive: false,
pagePrimary: 0,
pages: 1,
space: 'srgb',
width: 32
});
});
});