mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Upgrade to libvips 8.3.x
Add support for libvips' new native loaders, including GIF and SVG Pre-built binaries now include giflib and librsvg, exclude *magick
This commit is contained in:
BIN
test/fixtures/expected/svg1200.png
vendored
BIN
test/fixtures/expected/svg1200.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 574 B After Width: | Height: | Size: 504 B |
BIN
test/fixtures/expected/svg72.png
vendored
BIN
test/fixtures/expected/svg72.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 938 B After Width: | Height: | Size: 823 B |
BIN
test/fixtures/free-gearhead-pack.psd
vendored
BIN
test/fixtures/free-gearhead-pack.psd
vendored
Binary file not shown.
1
test/fixtures/index.js
vendored
1
test/fixtures/index.js
vendored
@@ -86,7 +86,6 @@ module.exports = {
|
||||
inputTiff: getPath('G31D.TIF'), // http://www.fileformat.info/format/tiff/sample/e6c9a6e5253348f4aef6d17b534360ab/index.htm
|
||||
inputGif: getPath('Crash_test.gif'), // http://upload.wikimedia.org/wikipedia/commons/e/e3/Crash_test.gif
|
||||
inputSvg: getPath('check.svg'), // http://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg
|
||||
inputPsd: getPath('free-gearhead-pack.psd'), // https://dribbble.com/shots/1624241-Free-Gearhead-Vector-Pack
|
||||
|
||||
inputSvs: getPath('CMU-1-Small-Region.svs'), // http://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/CMU-1-Small-Region.svs
|
||||
|
||||
|
||||
@@ -668,29 +668,25 @@ describe('Input/output', function() {
|
||||
});
|
||||
});
|
||||
|
||||
if (sharp.format.magick.input.file) {
|
||||
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) {
|
||||
if (err) {
|
||||
assert.strictEqual(0, err.message.indexOf('Input file is missing or of an unsupported image format'));
|
||||
done();
|
||||
} else {
|
||||
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) {
|
||||
if (err) throw 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) {
|
||||
@@ -699,38 +695,18 @@ describe('Input/output', function() {
|
||||
.extract({left: 290, top: 760, width: 40, height: 40})
|
||||
.toFormat('png')
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) {
|
||||
assert.strictEqual(0, err.message.indexOf('Input file is missing or of an unsupported image format'));
|
||||
done();
|
||||
} else {
|
||||
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;
|
||||
sharp(data).metadata(function(err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(1200, info.density);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (sharp.format.magick.input.file) {
|
||||
it('Convert PSD to PNG', function(done) {
|
||||
sharp(fixtures.inputPsd)
|
||||
.resize(320, 240)
|
||||
.toFormat(sharp.format.png)
|
||||
.toFile(fixtures.path('output.psd.png'), function(err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, info.size > 0);
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
done();
|
||||
assert.strictEqual(40, info.width);
|
||||
assert.strictEqual(40, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('svg1200.png'), data, function(err) {
|
||||
if (err) throw err;
|
||||
sharp(data).metadata(function(err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(1200, info.density);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -753,7 +729,7 @@ describe('Input/output', function() {
|
||||
});
|
||||
}
|
||||
|
||||
if (sharp.format.magick.input.buffer) {
|
||||
if (sharp.format.gif.input.buffer) {
|
||||
it('Load GIF from Buffer', function(done) {
|
||||
var inputGifBuffer = fs.readFileSync(fixtures.inputGif);
|
||||
sharp(inputGifBuffer)
|
||||
|
||||
@@ -133,7 +133,24 @@ describe('Image metadata', function() {
|
||||
});
|
||||
}
|
||||
|
||||
if (sharp.format.magick.input.file) {
|
||||
if (sharp.format.gif.input.file) {
|
||||
it('GIF via giflib', function(done) {
|
||||
sharp(fixtures.inputGif).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('gif', metadata.format);
|
||||
assert.strictEqual(800, metadata.width);
|
||||
assert.strictEqual(533, metadata.height);
|
||||
assert.strictEqual(4, metadata.channels);
|
||||
assert.strictEqual('undefined', typeof metadata.density);
|
||||
assert.strictEqual(false, metadata.hasProfile);
|
||||
assert.strictEqual(true, metadata.hasAlpha);
|
||||
assert.strictEqual('undefined', typeof metadata.orientation);
|
||||
assert.strictEqual('undefined', typeof metadata.exif);
|
||||
assert.strictEqual('undefined', typeof metadata.icc);
|
||||
done();
|
||||
});
|
||||
});
|
||||
} else if (sharp.format.magick.input.file) {
|
||||
it('GIF via libmagick', function(done) {
|
||||
sharp(fixtures.inputGif).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
|
||||
Reference in New Issue
Block a user