Prevent over-compute in affine rotate #3722

This commit is contained in:
Lovell Fuller 2023-07-09 09:04:07 +01:00
parent 0da55bab7e
commit 14c3346800
3 changed files with 20 additions and 1 deletions

View File

@ -16,6 +16,9 @@ Requires libvips v8.14.2
[#3674](https://github.com/lovell/sharp/pull/3674) [#3674](https://github.com/lovell/sharp/pull/3674)
[@bianjunjie1981](https://github.com/bianjunjie1981) [@bianjunjie1981](https://github.com/bianjunjie1981)
* Prevent over-compute in affine-based rotate before resize.
[#3722](https://github.com/lovell/sharp/issues/3722)
### v0.32.1 - 27th April 2023 ### v0.32.1 - 27th April 2023
* Add experimental `unflatten` operation. * Add experimental `unflatten` operation.

View File

@ -116,7 +116,7 @@ class PipelineWorker : public Napi::AsyncWorker {
MultiPageUnsupported(nPages, "Rotate"); MultiPageUnsupported(nPages, "Rotate");
std::vector<double> background; std::vector<double> background;
std::tie(image, background) = sharp::ApplyAlpha(image, baton->rotationBackground, FALSE); std::tie(image, background) = sharp::ApplyAlpha(image, baton->rotationBackground, FALSE);
image = image.rotate(baton->rotationAngle, VImage::option()->set("background", background)); image = image.rotate(baton->rotationAngle, VImage::option()->set("background", background)).cache();
} }
} }

View File

@ -473,4 +473,20 @@ describe('Rotation', function () {
assert.strictEqual(g, 64); assert.strictEqual(g, 64);
assert.strictEqual(b, 30); assert.strictEqual(b, 30);
}); });
it('Resize after affine-based rotation does not overcompute', async () =>
sharp({
create: {
width: 4640,
height: 2610,
channels: 3,
background: 'black'
}
})
.rotate(28)
.resize({ width: 640, height: 360 })
.raw()
.timeout({ seconds: 5 })
.toBuffer()
);
}); });