From 1bece3a7921b7f11deaf5ea20b41558b110f908b Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Sun, 1 May 2016 09:43:03 +0100 Subject: [PATCH] Add 2 channel (grey+alpha) GIF test case #375 --- test/fixtures/grey-plus-alpha.gif | Bin 0 -> 43 bytes test/fixtures/index.js | 1 + test/unit/io.js | 18 ++++++++++++++++++ test/unit/metadata.js | 15 +++++++-------- 4 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 test/fixtures/grey-plus-alpha.gif diff --git a/test/fixtures/grey-plus-alpha.gif b/test/fixtures/grey-plus-alpha.gif new file mode 100644 index 0000000000000000000000000000000000000000..7a4cb1e465eb329843b69971c5cdfa60d4ae1c6b GIT binary patch literal 43 tcmZ?wbhEHbWMW`sXkcJSO-=p(|G(l-7Dfi3fDQu?fMgh$m|VCRtO4R<2s8iy literal 0 HcmV?d00001 diff --git a/test/fixtures/index.js b/test/fixtures/index.js index 57924121..73048b30 100644 --- a/test/fixtures/index.js +++ b/test/fixtures/index.js @@ -85,6 +85,7 @@ module.exports = { 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 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 inputSvs: getPath('CMU-1-Small-Region.svs'), // http://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/CMU-1-Small-Region.svs diff --git a/test/unit/io.js b/test/unit/io.js index 0483a8db..77d44ff7 100644 --- a/test/unit/io.js +++ b/test/unit/io.js @@ -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) { it('Load Aperio SVS file via Openslide', function(done) { sharp(fixtures.inputSvs) diff --git a/test/unit/metadata.js b/test/unit/metadata.js index 66e089c8..b845fd67 100644 --- a/test/unit/metadata.js +++ b/test/unit/metadata.js @@ -150,17 +150,16 @@ describe('Image metadata', function() { done(); }); }); - } else if (sharp.format.magick.input.file) { - it('GIF via libmagick', function(done) { - sharp(fixtures.inputGif).metadata(function(err, metadata) { + it('GIF grey+alpha via giflib', function(done) { + sharp(fixtures.inputGifGreyPlusAlpha).metadata(function(err, metadata) { if (err) throw err; - assert.strictEqual('magick', metadata.format); - assert.strictEqual(800, metadata.width); - assert.strictEqual(533, metadata.height); - assert.strictEqual(3, metadata.channels); + assert.strictEqual('gif', metadata.format); + assert.strictEqual(2, metadata.width); + assert.strictEqual(1, metadata.height); + assert.strictEqual(4, metadata.channels); assert.strictEqual('undefined', typeof metadata.density); 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.exif); assert.strictEqual('undefined', typeof metadata.icc);