Tests: add PNG palette decode/encode roundtrip

This commit is contained in:
Lovell Fuller 2021-11-23 14:19:47 +00:00
parent e1ba2a7fd8
commit 336856dfc2
3 changed files with 7 additions and 0 deletions

View File

@ -93,6 +93,7 @@ module.exports = {
inputPngImageInAlpha: getPath('image-in-alpha.png'), // https://github.com/lovell/sharp/issues/1597 inputPngImageInAlpha: getPath('image-in-alpha.png'), // https://github.com/lovell/sharp/issues/1597
inputPngSolidAlpha: getPath('with-alpha.png'), // https://github.com/lovell/sharp/issues/1599 inputPngSolidAlpha: getPath('with-alpha.png'), // https://github.com/lovell/sharp/issues/1599
inputPngP3: getPath('p3.png'), // https://github.com/lovell/sharp/issues/2862 inputPngP3: getPath('p3.png'), // https://github.com/lovell/sharp/issues/2862
inputPngPalette: getPath('swiss.png'), // https://github.com/randy408/libspng/issues/188
inputWebP: getPath('4.webp'), // http://www.gstatic.com/webp/gallery/4.webp inputWebP: getPath('4.webp'), // http://www.gstatic.com/webp/gallery/4.webp
inputWebPWithTransparency: getPath('5_webp_a.webp'), // http://www.gstatic.com/webp/gallery3/5_webp_a.webp inputWebPWithTransparency: getPath('5_webp_a.webp'), // http://www.gstatic.com/webp/gallery3/5_webp_a.webp

BIN
test/fixtures/swiss.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -128,6 +128,12 @@ describe('PNG', function () {
assert.strictEqual(alphaMeanAfter, alphaMeanBefore); assert.strictEqual(alphaMeanAfter, alphaMeanBefore);
}); });
it('palette decode/encode roundtrip', () =>
sharp(fixtures.inputPngPalette)
.png({ effort: 1, palette: true })
.toBuffer()
);
it('Valid PNG libimagequant palette value does not throw error', function () { it('Valid PNG libimagequant palette value does not throw error', function () {
assert.doesNotThrow(function () { assert.doesNotThrow(function () {
sharp().png({ palette: false }); sharp().png({ palette: false });