Upgrade libvips to v8.4.2

Improved EXIF orientation and GIF alpha channel support
This commit is contained in:
Lovell Fuller
2016-10-15 19:07:25 +01:00
parent 1051fcd278
commit eb30f6ceff
19 changed files with 497 additions and 154 deletions

View File

@@ -668,48 +668,60 @@ describe('Input/output', function() {
});
});
if (sharp.format.svg.input.file) {
it('Convert SVG to PNG at default 72DPI', function(done) {
sharp(fixtures.inputSvg)
.resize(1024)
.extract({left: 290, top: 760, width: 40, height: 40})
.toFormat('png')
.toBuffer(function(err, data, info) {
it('Convert SVG to PNG at default 72DPI', function(done) {
sharp(fixtures.inputSvg)
.resize(1024)
.extract({left: 290, top: 760, width: 40, height: 40})
.toFormat('png')
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual('png', info.format);
assert.strictEqual(40, info.width);
assert.strictEqual(40, info.height);
fixtures.assertSimilar(fixtures.expected('svg72.png'), data, function(err) {
if (err) throw err;
assert.strictEqual('png', info.format);
assert.strictEqual(40, info.width);
assert.strictEqual(40, info.height);
fixtures.assertSimilar(fixtures.expected('svg72.png'), data, function(err) {
sharp(data).metadata(function(err, info) {
if (err) throw err;
sharp(data).metadata(function(err, info) {
if (err) throw err;
assert.strictEqual(72, info.density);
done();
});
assert.strictEqual(72, info.density);
done();
});
});
});
it('Convert SVG to PNG at 300DPI', function(done) {
sharp(fixtures.inputSvg, { density: 1200 })
.resize(1024)
.extract({left: 290, top: 760, width: 40, height: 40})
.toFormat('png')
.toBuffer(function(err, data, info) {
});
});
it('Convert SVG to PNG at 300DPI', function(done) {
sharp(fixtures.inputSvg, { density: 1200 })
.resize(1024)
.extract({left: 290, top: 760, width: 40, height: 40})
.toFormat('png')
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual('png', info.format);
assert.strictEqual(40, info.width);
assert.strictEqual(40, info.height);
fixtures.assertSimilar(fixtures.expected('svg1200.png'), data, function(err) {
if (err) throw err;
assert.strictEqual('png', info.format);
assert.strictEqual(40, info.width);
assert.strictEqual(40, info.height);
fixtures.assertSimilar(fixtures.expected('svg1200.png'), data, function(err) {
sharp(data).metadata(function(err, info) {
if (err) throw err;
sharp(data).metadata(function(err, info) {
if (err) throw err;
assert.strictEqual(1200, info.density);
done();
});
assert.strictEqual(1200, info.density);
done();
});
});
});
}
});
});
it('Convert SVG with embedded images to PNG, respecting dimensions', function(done) {
sharp(fixtures.inputSvgWithEmbeddedImages)
.png()
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual('png', info.format);
assert.strictEqual(480, info.width);
assert.strictEqual(360, info.height);
assert.strictEqual(4, info.channels);
fixtures.assertSimilar(fixtures.expected('svg-embedded.png'), data, done);
});
});
if (sharp.format.tiff.input.buffer) {
it('Load TIFF from Buffer', function(done) {
@@ -765,22 +777,6 @@ describe('Input/output', function() {
});
}
if (sharp.format.openslide.input.file) {
it('Load Aperio SVS file via Openslide', function(done) {
sharp(fixtures.inputSvs)
.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();
});
});
}
if (sharp.format.v.input.file) {
it("Load Vips V file", function(done) {
sharp(fixtures.inputV)

View File

@@ -69,7 +69,7 @@ describe('Image metadata', function() {
assert.strictEqual(300, metadata.density);
assert.strictEqual(false, metadata.hasProfile);
assert.strictEqual(false, metadata.hasAlpha);
assert.strictEqual('undefined', typeof metadata.orientation);
assert.strictEqual(1, metadata.orientation);
assert.strictEqual('undefined', typeof metadata.exif);
assert.strictEqual('undefined', typeof metadata.icc);
done();
@@ -140,10 +140,10 @@ describe('Image metadata', function() {
assert.strictEqual('gif', metadata.format);
assert.strictEqual(800, metadata.width);
assert.strictEqual(533, metadata.height);
assert.strictEqual(4, metadata.channels);
assert.strictEqual(3, metadata.channels);
assert.strictEqual('undefined', typeof metadata.density);
assert.strictEqual(false, metadata.hasProfile);
assert.strictEqual(true, metadata.hasAlpha);
assert.strictEqual(false, metadata.hasAlpha);
assert.strictEqual('undefined', typeof metadata.orientation);
assert.strictEqual('undefined', typeof metadata.exif);
assert.strictEqual('undefined', typeof metadata.icc);
@@ -156,7 +156,7 @@ describe('Image metadata', function() {
assert.strictEqual('gif', metadata.format);
assert.strictEqual(2, metadata.width);
assert.strictEqual(1, metadata.height);
assert.strictEqual(4, metadata.channels);
assert.strictEqual(2, metadata.channels);
assert.strictEqual('undefined', typeof metadata.density);
assert.strictEqual(false, metadata.hasProfile);
assert.strictEqual(true, metadata.hasAlpha);

View File

@@ -127,7 +127,7 @@ describe('Rotation', function() {
assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height);
sharp(data).metadata(function(err, metadata) {
assert.strictEqual(false, 'orientation' in metadata);
assert.strictEqual(1, metadata.orientation);
fixtures.assertSimilar(fixtures.expected('exif-5.jpg'), data, done);
});
});
@@ -177,7 +177,7 @@ describe('Rotation', function() {
assert.strictEqual(261, info.height);
sharp(data).metadata(function(err, metadata) {
if (err) throw err;
assert.strictEqual(false, 'orientation' in metadata);
assert.strictEqual(1, metadata.orientation);
fixtures.assertSimilar(fixtures.expected('flip.jpg'), data, done);
});
});
@@ -195,7 +195,7 @@ describe('Rotation', function() {
assert.strictEqual(261, info.height);
sharp(data).metadata(function(err, metadata) {
if (err) throw err;
assert.strictEqual(false, 'orientation' in metadata);
assert.strictEqual(1, metadata.orientation);
fixtures.assertSimilar(fixtures.expected('flop.jpg'), data, done);
});
});

View File

@@ -144,10 +144,10 @@ describe('Tile', function() {
if (sharp.format.dz.output.file) {
it('Deep Zoom layout', function(done) {
var directory = fixtures.path('output.dz_files');
var directory = fixtures.path('output.dzi_files');
rimraf(directory, function() {
sharp(fixtures.inputJpg)
.toFile(fixtures.path('output.dz.dzi'), function(err, info) {
.toFile(fixtures.path('output.dzi'), function(err, info) {
if (err) throw err;
assert.strictEqual('dz', info.format);
assertDeepZoomTiles(directory, 256, 13, done);
@@ -156,14 +156,14 @@ describe('Tile', function() {
});
it('Deep Zoom layout with custom size+overlap', function(done) {
var directory = fixtures.path('output.dz.512_files');
var directory = fixtures.path('output.512.dzi_files');
rimraf(directory, function() {
sharp(fixtures.inputJpg)
.tile({
size: 512,
overlap: 16
})
.toFile(fixtures.path('output.dz.512.dzi'), function(err, info) {
.toFile(fixtures.path('output.512.dzi'), function(err, info) {
if (err) throw err;
assert.strictEqual('dz', info.format);
assertDeepZoomTiles(directory, 512 + 2 * 16, 13, done);
@@ -172,7 +172,7 @@ describe('Tile', function() {
});
it('Zoomify layout', function(done) {
var directory = fixtures.path('output.zoomify');
var directory = fixtures.path('output.zoomify.dzi');
rimraf(directory, function() {
sharp(fixtures.inputJpg)
.tile({
@@ -192,13 +192,13 @@ describe('Tile', function() {
});
it('Google layout', function(done) {
var directory = fixtures.path('output.google');
var directory = fixtures.path('output.google.dzi');
rimraf(directory, function() {
sharp(fixtures.inputJpg)
.tile({
layout: 'google'
})
.toFile(fixtures.path('output.google.dzi'), function(err, info) {
.toFile(directory, function(err, info) {
if (err) throw err;
assert.strictEqual('dz', info.format);
fs.stat(path.join(directory, '0', '0', '0.jpg'), function(err, stat) {
@@ -244,7 +244,7 @@ describe('Tile', function() {
.tile({
container: 'zip'
})
.toFile(fixtures.path('output.dz.containeropt.dzi'), function(err, info) {
.toFile(container, function(err, info) {
// Vips overrides .dzi extension to .zip used by container var below
if (err) throw err;
assert.strictEqual('dz', info.format);