Expose control over CPU effort for palette PNG #2541

This commit is contained in:
Lovell Fuller
2021-11-24 17:12:53 +00:00
parent 140eeebb3d
commit 72025051c5
7 changed files with 27 additions and 3 deletions

View File

@@ -143,8 +143,8 @@ describe('PNG', function () {
it('Valid PNG libimagequant quality value produces image of same size or smaller', function () {
const inputPngBuffer = fs.readFileSync(fixtures.inputPng);
return Promise.all([
sharp(inputPngBuffer).resize(10).png({ quality: 80 }).toBuffer(),
sharp(inputPngBuffer).resize(10).png({ quality: 100 }).toBuffer()
sharp(inputPngBuffer).resize(10).png({ effort: 1, quality: 80 }).toBuffer(),
sharp(inputPngBuffer).resize(10).png({ effort: 1, quality: 100 }).toBuffer()
]).then(function (data) {
assert.strictEqual(true, data[0].length <= data[1].length);
});
@@ -156,6 +156,12 @@ describe('PNG', function () {
});
});
it('Invalid effort value throws error', () => {
assert.throws(() => {
sharp().png({ effort: 0.1 });
});
});
it('Valid PNG libimagequant colours value produces image of same size or smaller', function () {
const inputPngBuffer = fs.readFileSync(fixtures.inputPng);
return Promise.all([