diff --git a/docs/changelog.md b/docs/changelog.md index 7c38cd04d..e51cef656 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -10,6 +10,9 @@ Requires libvips v8.11.3 * Ensure `sharp.versions` is populated from vendored libvips. +* Remove animation properties from single page images. + [#2890](https://github.com/lovell/sharp/issues/2890) + * Allow use of 'tif' to select TIFF output. [#2893](https://github.com/lovell/sharp/pull/2893) [@erf](https://github.com/erf) diff --git a/src/pipeline.cc b/src/pipeline.cc index 3a3763429..2ca99c00b 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -289,6 +289,10 @@ class PipelineWorker : public Napi::AsyncWorker { yfactor = static_cast(shrunkOnLoadHeight) / static_cast(targetResizeHeight); } } + // Remove animation properties from single page images + if (baton->input->pages == 1) { + image = sharp::RemoveAnimationProperties(image); + } // Ensure we're using a device-independent colour space char const *processingProfile = image.interpretation() == VIPS_INTERPRETATION_RGB16 ? "p3" : "srgb"; diff --git a/test/unit/webp.js b/test/unit/webp.js index dd9b38a31..4dd39ae12 100644 --- a/test/unit/webp.js +++ b/test/unit/webp.js @@ -209,4 +209,24 @@ describe('WebP', function () { fixtures.assertSimilar(fixtures.inputWebPAnimated, data, done); }); }); + + it('should remove animation properties when loading single page', async () => { + const data = await sharp(fixtures.inputGifAnimatedLoop3) + .resize({ height: 570 }) + .webp({ reductionEffort: 0 }) + .toBuffer(); + const metadata = await sharp(data).metadata(); + assert.deepStrictEqual(metadata, { + format: 'webp', + size: 2580, + width: 740, + height: 570, + space: 'srgb', + channels: 3, + depth: 'uchar', + isProgressive: false, + hasProfile: false, + hasAlpha: false + }); + }); });