Skip to content

Commit

Permalink
Remove animation props from single page images #2890
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Oct 18, 2021
1 parent 7ae1513 commit d359331
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
20 changes: 20 additions & 0 deletions test/unit/webp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
});
});

0 comments on commit d359331

Please sign in to comment.