mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure background metadata can be parsed #4090
This commit is contained in:
BIN
test/fixtures/bgbn4a08.png
vendored
Normal file
BIN
test/fixtures/bgbn4a08.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 140 B |
BIN
test/fixtures/bggn4a16.png
vendored
Normal file
BIN
test/fixtures/bggn4a16.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
2
test/fixtures/index.js
vendored
2
test/fixtures/index.js
vendored
@@ -80,6 +80,8 @@ module.exports = {
|
||||
inputPngWithGreyAlpha: getPath('grey-8bit-alpha.png'),
|
||||
inputPngWithOneColor: getPath('2x2_fdcce6.png'),
|
||||
inputPngWithTransparency16bit: getPath('tbgn2c16.png'), // http://www.schaik.com/pngsuite/tbgn2c16.png
|
||||
inputPng8BitGreyBackground: getPath('bgbn4a08.png'), // http://www.schaik.com/pngsuite/bgbn4a08.png
|
||||
inputPng16BitGreyBackground: getPath('bggn4a16.png'), // http://www.schaik.com/pngsuite/bggn4a16.png
|
||||
inputPng16BitGreyAlpha: getPath('16-bit-grey-alpha.png'), // CC-BY-NC-SA florc http://www.colourlovers.com/pattern/50713/pat
|
||||
inputPngOverlayLayer0: getPath('alpha-layer-0-background.png'),
|
||||
inputPngOverlayLayer1: getPath('alpha-layer-1-fill.png'),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user