Add 2 channel (grey+alpha) GIF test case #375

This commit is contained in:
Lovell Fuller 2016-05-01 09:43:03 +01:00
parent 1de0038516
commit 1bece3a792
4 changed files with 26 additions and 8 deletions

BIN
test/fixtures/grey-plus-alpha.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

View File

@ -85,6 +85,7 @@ module.exports = {
inputWebPWithTransparency: getPath('5_webp_a.webp'), // http://www.gstatic.com/webp/gallery3/5_webp_a.webp inputWebPWithTransparency: getPath('5_webp_a.webp'), // http://www.gstatic.com/webp/gallery3/5_webp_a.webp
inputTiff: getPath('G31D.TIF'), // http://www.fileformat.info/format/tiff/sample/e6c9a6e5253348f4aef6d17b534360ab/index.htm 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 inputGif: getPath('Crash_test.gif'), // http://upload.wikimedia.org/wikipedia/commons/e/e3/Crash_test.gif
inputGifGreyPlusAlpha: getPath('grey-plus-alpha.gif'), // http://i.imgur.com/gZ5jlmE.gif
inputSvg: getPath('check.svg'), // http://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg inputSvg: getPath('check.svg'), // http://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg
inputSvs: getPath('CMU-1-Small-Region.svs'), // http://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/CMU-1-Small-Region.svs inputSvs: getPath('CMU-1-Small-Region.svs'), // http://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/CMU-1-Small-Region.svs

View File

@ -747,6 +747,24 @@ describe('Input/output', function() {
}); });
} }
if (sharp.format.gif.input.file) {
it('Load GIF grey+alpha from file', function(done) {
sharp(fixtures.inputGifGreyPlusAlpha)
.resize(8, 4)
.png()
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual(true, data.length > 0);
assert.strictEqual(data.length, info.size);
assert.strictEqual('png', info.format);
assert.strictEqual(8, info.width);
assert.strictEqual(4, info.height);
assert.strictEqual(4, info.channels);
done();
});
});
}
if (sharp.format.openslide.input.file) { if (sharp.format.openslide.input.file) {
it('Load Aperio SVS file via Openslide', function(done) { it('Load Aperio SVS file via Openslide', function(done) {
sharp(fixtures.inputSvs) sharp(fixtures.inputSvs)

View File

@ -150,17 +150,16 @@ describe('Image metadata', function() {
done(); done();
}); });
}); });
} else if (sharp.format.magick.input.file) { it('GIF grey+alpha via giflib', function(done) {
it('GIF via libmagick', function(done) { sharp(fixtures.inputGifGreyPlusAlpha).metadata(function(err, metadata) {
sharp(fixtures.inputGif).metadata(function(err, metadata) {
if (err) throw err; if (err) throw err;
assert.strictEqual('magick', metadata.format); assert.strictEqual('gif', metadata.format);
assert.strictEqual(800, metadata.width); assert.strictEqual(2, metadata.width);
assert.strictEqual(533, metadata.height); assert.strictEqual(1, metadata.height);
assert.strictEqual(3, metadata.channels); assert.strictEqual(4, metadata.channels);
assert.strictEqual('undefined', typeof metadata.density); assert.strictEqual('undefined', typeof metadata.density);
assert.strictEqual(false, metadata.hasProfile); assert.strictEqual(false, metadata.hasProfile);
assert.strictEqual(false, metadata.hasAlpha); assert.strictEqual(true, metadata.hasAlpha);
assert.strictEqual('undefined', typeof metadata.orientation); assert.strictEqual('undefined', typeof metadata.orientation);
assert.strictEqual('undefined', typeof metadata.exif); assert.strictEqual('undefined', typeof metadata.exif);
assert.strictEqual('undefined', typeof metadata.icc); assert.strictEqual('undefined', typeof metadata.icc);