mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Respect fastShrinkOnLoad option for WebP input #3516
This commit is contained in:
parent
9f79f80a93
commit
c150263ef1
@ -32,6 +32,9 @@ Requires libvips v8.14.0
|
||||
[#3470](https://github.com/lovell/sharp/pull/3470)
|
||||
[@ejoebstl](https://github.com/ejoebstl)
|
||||
|
||||
* Respect `fastShrinkOnLoad` resize option for WebP input.
|
||||
[#3516](https://github.com/lovell/sharp/issues/3516)
|
||||
|
||||
* Reduce sharpen `sigma` maximum from 10000 to 10.
|
||||
[#3521](https://github.com/lovell/sharp/issues/3521)
|
||||
|
||||
|
@ -205,7 +205,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
if (jpegShrinkOnLoad > 1 && static_cast<int>(shrink) == jpegShrinkOnLoad) {
|
||||
jpegShrinkOnLoad /= 2;
|
||||
}
|
||||
} else if (inputImageType == sharp::ImageType::WEBP && shrink > 1.0) {
|
||||
} else if (inputImageType == sharp::ImageType::WEBP && baton->fastShrinkOnLoad && shrink > 1.0) {
|
||||
// Avoid upscaling via webp
|
||||
scale = 1.0 / shrink;
|
||||
} else if (inputImageType == sharp::ImageType::SVG ||
|
||||
|
@ -115,6 +115,14 @@ describe('WebP', function () {
|
||||
)
|
||||
);
|
||||
|
||||
it('should produce different file size with/out shrink-on-load', async () => {
|
||||
const [shrunk, resized] = await Promise.all([
|
||||
sharp(fixtures.inputWebP).resize({ width: 16 }).toBuffer(),
|
||||
sharp(fixtures.inputWebP).resize({ width: 16, fastShrinkOnLoad: false, kernel: 'nearest' }).toBuffer()
|
||||
]);
|
||||
assert.notStrictEqual(shrunk.length, resized.length);
|
||||
});
|
||||
|
||||
it('invalid effort throws', () => {
|
||||
assert.throws(() => {
|
||||
sharp().webp({ effort: true });
|
||||
|
Loading…
x
Reference in New Issue
Block a user