From 00e65f6f14b837e2eb448a96e0dd2e9479533492 Mon Sep 17 00:00:00 2001 From: Denis Soldatov Date: Fri, 28 Aug 2020 15:39:19 +0300 Subject: [PATCH] Ensure correct pageHeight when verifying image dimensions (#2343) --- src/common.cc | 4 ++-- test/fixtures/big-height.webp | Bin 0 -> 7222 bytes test/fixtures/index.js | 1 + test/unit/toBuffer.js | 8 ++++++++ 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/big-height.webp diff --git a/src/common.cc b/src/common.cc index 612dd7ef..c7c7b73c 100644 --- a/src/common.cc +++ b/src/common.cc @@ -485,8 +485,8 @@ namespace sharp { Check the proposed format supports the current dimensions. */ void AssertImageTypeDimensions(VImage image, ImageType const imageType) { - const int height = image.get_typeof("pageHeight") == G_TYPE_INT - ? image.get_int("pageHeight") + const int height = image.get_typeof(VIPS_META_PAGE_HEIGHT) == G_TYPE_INT + ? image.get_int(VIPS_META_PAGE_HEIGHT) : image.height(); if (imageType == ImageType::JPEG) { if (image.width() > 65535 || height > 65535) { diff --git a/test/fixtures/big-height.webp b/test/fixtures/big-height.webp new file mode 100644 index 0000000000000000000000000000000000000000..752a1696414138d543a50e8451775dc1f00b6c66 GIT binary patch literal 7222 zcmWIYbaT^_VPFV%bqWXzu!!JdU|?VZVjc#D6$}iHexAN;K;C~K0P%d?oPazCfT%bD zCEW1*@gn{ATzt9Unm7^w& zhSO*&7|kuCWx;5fIa(u()|{j5g3<{9 literal 0 HcmV?d00001 diff --git a/test/fixtures/index.js b/test/fixtures/index.js index 9557f4a2..dab08814 100644 --- a/test/fixtures/index.js +++ b/test/fixtures/index.js @@ -95,6 +95,7 @@ module.exports = { inputWebPWithTransparency: getPath('5_webp_a.webp'), // http://www.gstatic.com/webp/gallery3/5_webp_a.webp inputWebPAnimated: getPath('rotating-squares.webp'), // http://www.gstatic.com/webp/gallery3/5_webp_a.webp inputWebPAnimatedLoop3: getPath('animated-loop-3.webp'), // http://www.gstatic.com/webp/gallery3/5_webp_a.webp + inputWebPAnimatedBigHeight: getPath('big-height.webp'), inputTiff: getPath('G31D.TIF'), // http://www.fileformat.info/format/tiff/sample/e6c9a6e5253348f4aef6d17b534360ab/index.htm inputTiffMultipage: getPath('G31D_MULTI.TIF'), // gm convert G31D.TIF -resize 50% G31D_2.TIF ; tiffcp G31D.TIF G31D_2.TIF G31D_MULTI.TIF inputTiffCielab: getPath('cielab-dagams.tiff'), // https://github.com/lovell/sharp/issues/646 diff --git a/test/unit/toBuffer.js b/test/unit/toBuffer.js index 25637a85..3759f524 100644 --- a/test/unit/toBuffer.js +++ b/test/unit/toBuffer.js @@ -16,4 +16,12 @@ describe('toBuffer', () => { }); }); }); + + it('correctly process animated webp with height > 16383', (done) => { + const image = sharp(fixtures.inputWebPAnimatedBigHeight, { animated: true }); + image.toBuffer().then((buff) => { + assert.strictEqual(Buffer.isBuffer(buff), true); + done(); + }); + }); });