diff --git a/test/unit/png.js b/test/unit/png.js index 92feb25e0..9db15854e 100644 --- a/test/unit/png.js +++ b/test/unit/png.js @@ -128,6 +128,45 @@ describe('PNG', function () { assert.strictEqual(alphaMeanAfter, alphaMeanBefore); }); + it('RGB palette PNG decode', async () => { + const rgb = await sharp(fixtures.inputJpg) + .resize(8, 8) + .png({ palette: true }) + .toBuffer(); + + const { info } = await sharp(rgb) + .toBuffer({ resolveWithObject: true }); + const { size, ...infoWithoutSize } = info; + + assert.deepStrictEqual(infoWithoutSize, { + format: 'png', + width: 8, + height: 8, + channels: 3, + premultiplied: false + }); + }); + + it('RGBA palette PNG decode', async () => { + const rgba = await sharp(fixtures.inputJpg) + .resize(8, 8) + .ensureAlpha(0.5) + .png({ palette: true }) + .toBuffer(); + + const { info } = await sharp(rgba) + .toBuffer({ resolveWithObject: true }); + const { size, ...infoWithoutSize } = info; + + assert.deepStrictEqual(infoWithoutSize, { + format: 'png', + width: 8, + height: 8, + channels: 4, + premultiplied: false + }); + }); + it('Valid PNG libimagequant palette value does not throw error', function () { assert.doesNotThrow(function () { sharp().png({ palette: false });