Remove animation props from single page images #2890

This commit is contained in:
Lovell Fuller 2021-10-18 20:27:10 +01:00
parent 7ae151362b
commit d359331426
3 changed files with 27 additions and 0 deletions

View File

@ -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)

View File

@ -289,6 +289,10 @@ class PipelineWorker : public Napi::AsyncWorker {
yfactor = static_cast<double>(shrunkOnLoadHeight) / static_cast<double>(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";

View File

@ -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
});
});
});