mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add features from libvips 7.40+
Load TIFF from Buffer/Stream Interlaced PNG output no longer needs tilecache Option to disable PNG adaptive row filtering
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
var fs = require('fs');
|
||||
var assert = require('assert');
|
||||
|
||||
var semver = require('semver');
|
||||
|
||||
var sharp = require('../../index');
|
||||
var fixtures = require('../fixtures');
|
||||
|
||||
@@ -343,9 +345,9 @@ describe('Input/output', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('PNG compression level', function() {
|
||||
describe('PNG output', function() {
|
||||
|
||||
it('valid', function(done) {
|
||||
it('compression level is valid', function(done) {
|
||||
var isValid = false;
|
||||
try {
|
||||
sharp().compressionLevel(0);
|
||||
@@ -355,7 +357,7 @@ describe('Input/output', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
it('invalid', function(done) {
|
||||
it('compression level is invalid', function(done) {
|
||||
var isValid = false;
|
||||
try {
|
||||
sharp().compressionLevel(-1);
|
||||
@@ -365,6 +367,52 @@ describe('Input/output', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
if (semver.gte(sharp.libvipsVersion(), '7.41.0')) {
|
||||
it('withoutAdaptiveFiltering generates smaller file [libvips 7.41.0+]', function(done) {
|
||||
// First generate with adaptive filtering
|
||||
sharp(fixtures.inputPng)
|
||||
.resize(320, 240)
|
||||
.withoutAdaptiveFiltering(false)
|
||||
.toBuffer(function(err, dataAdaptive, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, dataAdaptive.length > 0);
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
// Then generate without
|
||||
sharp(fixtures.inputPng)
|
||||
.resize(320, 240)
|
||||
.withoutAdaptiveFiltering()
|
||||
.toBuffer(function(err, dataWithoutAdaptive, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, dataWithoutAdaptive.length > 0);
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
assert.strictEqual(true, dataWithoutAdaptive.length < dataAdaptive.length);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (semver.gte(sharp.libvipsVersion(), '7.40.0')) {
|
||||
it('Load TIFF from Buffer [libvips 7.40.0+]', function(done) {
|
||||
var inputTiffBuffer = fs.readFileSync(fixtures.inputTiff);
|
||||
sharp(inputTiffBuffer)
|
||||
.resize(320, 240)
|
||||
.jpeg()
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user