mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Upgrade to libvips 8.10.6-alpha1
- Prebuilt binaries now include mozjpeg and libimagequant (BSD 2-Clause) - Prebuilt binaries limit AVIF support to the most common 8-bit depth - Add `mozjpeg` option to `jpeg` method, sets mozjpeg defaults - Reduce the default PNG `compressionLevel` to the more commonly used 6
This commit is contained in:
@@ -290,4 +290,24 @@ describe('JPEG', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Can use mozjpeg defaults', async () => {
|
||||
const withoutData = await sharp(fixtures.inputJpg)
|
||||
.resize(32, 24)
|
||||
.jpeg({ mozjpeg: false })
|
||||
.toBuffer();
|
||||
const withoutMeta = await sharp(withoutData).metadata();
|
||||
assert.strictEqual(false, withoutMeta.isProgressive);
|
||||
|
||||
const withData = await sharp(fixtures.inputJpg)
|
||||
.resize(32, 24)
|
||||
.jpeg({ mozjpeg: true })
|
||||
.toBuffer();
|
||||
const withMeta = await sharp(withData).metadata();
|
||||
assert.strictEqual(true, withMeta.isProgressive);
|
||||
});
|
||||
|
||||
it('Invalid mozjpeg value throws error', () => {
|
||||
assert.throws(() => sharp().jpeg({ mozjpeg: 'fail' }));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('PNG', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('default compressionLevel generates smaller file than compressionLevel=6', function (done) {
|
||||
it('default compressionLevel generates smaller file than compressionLevel=0', function (done) {
|
||||
// First generate with default compressionLevel
|
||||
sharp(fixtures.inputPng)
|
||||
.resize(320, 240)
|
||||
@@ -31,7 +31,7 @@ describe('PNG', function () {
|
||||
// Then generate with compressionLevel=6
|
||||
sharp(fixtures.inputPng)
|
||||
.resize(320, 240)
|
||||
.png({ compressionLevel: 6 })
|
||||
.png({ compressionLevel: 0 })
|
||||
.toBuffer(function (err, largerData, largerInfo) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, largerData.length > 0);
|
||||
|
||||
@@ -279,7 +279,7 @@ describe('TIFF', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('TIFF deflate compression of integral input with float predictor increases file size', function (done) {
|
||||
it('TIFF deflate compression with float predictor shrinks test file', function (done) {
|
||||
const startSize = fs.statSync(fixtures.inputTiffUncompressed).size;
|
||||
sharp(fixtures.inputTiffUncompressed)
|
||||
.tiff({
|
||||
@@ -289,7 +289,7 @@ describe('TIFF', function () {
|
||||
.toFile(outputTiff, (err, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('tiff', info.format);
|
||||
assert(info.size > startSize);
|
||||
assert(startSize > info.size);
|
||||
rimraf(outputTiff, done);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user