Ensure PNG bitdepth can be set for non-palette output #3322

This commit is contained in:
Lovell Fuller
2022-08-22 14:57:12 +01:00
parent e1bc8674fd
commit 3a44748f49
3 changed files with 28 additions and 8 deletions

View File

@@ -190,6 +190,23 @@ describe('PNG', function () {
});
});
it('Can set bitdepth of PNG without palette', async () => {
const data = await sharp({
create: {
width: 8, height: 8, channels: 3, background: 'red'
}
})
.toColourspace('b-w')
.png({ colours: 2, palette: false })
.toBuffer();
const { channels, paletteBitDepth, size, space } = await sharp(data).metadata();
assert.strictEqual(channels, 1);
assert.strictEqual(paletteBitDepth, undefined);
assert.strictEqual(size, 90);
assert.strictEqual(space, 'b-w');
});
it('Valid PNG libimagequant dither value produces image of same size or smaller', function () {
const inputPngBuffer = fs.readFileSync(fixtures.inputPng);
return Promise.all([