Ensure background metadata can be parsed #4090

This commit is contained in:
Lovell Fuller
2024-11-02 13:03:58 +00:00
parent 3796dd8a87
commit 04e7f58cea
9 changed files with 55 additions and 7 deletions

View File

@@ -201,6 +201,48 @@ describe('Image metadata', function () {
});
});
it('PNG with greyscale bKGD chunk - 8 bit', async () => {
const data = await sharp(fixtures.inputPng8BitGreyBackground).metadata();
assert.deepStrictEqual(data, {
background: {
gray: 0
},
bitsPerSample: 8,
channels: 2,
density: 72,
depth: 'uchar',
format: 'png',
hasAlpha: true,
hasProfile: false,
height: 32,
isPalette: false,
isProgressive: false,
space: 'b-w',
width: 32
});
});
it('PNG with greyscale bKGD chunk - 16 bit', async () => {
const data = await sharp(fixtures.inputPng16BitGreyBackground).metadata();
assert.deepStrictEqual(data, {
background: {
gray: 67
},
bitsPerSample: 16,
channels: 2,
density: 72,
depth: 'ushort',
format: 'png',
hasAlpha: true,
hasProfile: false,
height: 32,
isPalette: false,
isProgressive: false,
space: 'grey16',
width: 32
});
});
it('WebP', function (done) {
sharp(fixtures.inputWebP).metadata(function (err, metadata) {
if (err) throw err;