From 7aa340232e58ef6db104f6e70f63e1eea60c658e Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Fri, 28 Jan 2022 12:50:31 +0100 Subject: [PATCH] Ensure delays of the origin image is preserved (#3062) By not initializing the delay vector, since we assume it's empty by default. See: #3061. --- src/pipeline.h | 1 - test/unit/webp.js | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pipeline.h b/src/pipeline.h index b0cca2b16..f9d95b18f 100644 --- a/src/pipeline.h +++ b/src/pipeline.h @@ -327,7 +327,6 @@ struct PipelineBaton { ensureAlpha(-1.0), colourspaceInput(VIPS_INTERPRETATION_LAST), colourspace(VIPS_INTERPRETATION_LAST), - delay{-1}, loop(-1), tileSize(256), tileOverlap(0), diff --git a/test/unit/webp.js b/test/unit/webp.js index f87f3caf0..a9b818f85 100644 --- a/test/unit/webp.js +++ b/test/unit/webp.js @@ -183,6 +183,15 @@ describe('WebP', function () { assert.deepStrictEqual(updated.delay, expectedDelay); }); + it('should preserve delay between frames', async () => { + const updated = await sharp(fixtures.inputWebPAnimated, { pages: -1 }) + .webp() + .toBuffer() + .then(data => sharp(data, { pages: -1 }).metadata()); + + assert.deepStrictEqual(updated.delay, [120, 120, 90, 120, 120, 90, 120, 90, 30]); + }); + it('should work with streams when only animated is set', function (done) { fs.createReadStream(fixtures.inputWebPAnimated) .pipe(sharp({ animated: true }))