Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use vips to upsample webp #3267

Merged
merged 2 commits into from Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pipeline.cc
Expand Up @@ -217,7 +217,7 @@ class PipelineWorker : public Napi::AsyncWorker {
->set("access", baton->input->access)
->set("scale", scale)
->set("fail_on", baton->input->failOn);
if (inputImageType == sharp::ImageType::WEBP) {
if (scale < 1.0 && inputImageType == sharp::ImageType::WEBP) {
lovell marked this conversation as resolved.
Show resolved Hide resolved
option->set("n", baton->input->pages);
option->set("page", baton->input->page);

Expand Down
14 changes: 14 additions & 0 deletions test/unit/resize.js
Expand Up @@ -121,6 +121,20 @@ describe('Resize dimensions', function () {
});
});

it('Webp resize then extract large image', function (done) {
sharp(fixtures.inputWebP)
.resize(0x4000, 0x4000)
.extract({ top: 0x2000, left: 0x2000, width: 256, height: 256 })
.webp()
.toBuffer(function (err, data, info) {
if (err) throw err;
assert.strictEqual('webp', info.format);
assert.strictEqual(256, info.width);
assert.strictEqual(256, info.height);
done();
});
});

it('WebP shrink-on-load rounds to zero, ensure recalculation is correct', function (done) {
sharp(fixtures.inputJpg)
.resize(1080, 607)
Expand Down