mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Default PNG output to adaptiveFiltering=false, compressionLevel=9
PNG is mostly used for logos and line art, so these defaults will produce the smallest files for most output most of the time.
This commit is contained in:
@@ -628,6 +628,29 @@ describe('Input/output', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('default compressionLevel generates smaller file than compressionLevel=6', function (done) {
|
||||
// First generate with default compressionLevel
|
||||
sharp(fixtures.inputPng)
|
||||
.resize(320, 240)
|
||||
.png()
|
||||
.toBuffer(function (err, defaultData, defaultInfo) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, defaultData.length > 0);
|
||||
assert.strictEqual('png', defaultInfo.format);
|
||||
// Then generate with compressionLevel=6
|
||||
sharp(fixtures.inputPng)
|
||||
.resize(320, 240)
|
||||
.png({ compressionLevel: 6 })
|
||||
.toBuffer(function (err, largerData, largerInfo) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, largerData.length > 0);
|
||||
assert.strictEqual('png', largerInfo.format);
|
||||
assert.strictEqual(true, defaultData.length < largerData.length);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('without adaptiveFiltering generates smaller file', function (done) {
|
||||
// First generate with adaptive filtering
|
||||
sharp(fixtures.inputPng)
|
||||
|
||||
Reference in New Issue
Block a user