mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Ensure resize fit=inside respects 90/270 rotate #3756
This commit is contained in:
parent
3d01775972
commit
5c19f6dd9b
@ -14,6 +14,9 @@ Requires libvips v8.14.3
|
|||||||
[#3755](https://github.com/lovell/sharp/pull/3755)
|
[#3755](https://github.com/lovell/sharp/pull/3755)
|
||||||
[@kleisauke](https://github.com/kleisauke)
|
[@kleisauke](https://github.com/kleisauke)
|
||||||
|
|
||||||
|
* Ensure resize with a `fit` of `inside` respects 90/270 degree rotation.
|
||||||
|
[#3756](https://github.com/lovell/sharp/issues/3756)
|
||||||
|
|
||||||
* TypeScript: Ensure `minSize` property of `WebpOptions` is boolean.
|
* TypeScript: Ensure `minSize` property of `WebpOptions` is boolean.
|
||||||
[#3758](https://github.com/lovell/sharp/pull/3758)
|
[#3758](https://github.com/lovell/sharp/pull/3758)
|
||||||
[@sho-xizz](https://github.com/sho-xizz)
|
[@sho-xizz](https://github.com/sho-xizz)
|
||||||
|
@ -968,6 +968,9 @@ namespace sharp {
|
|||||||
if (swap && canvas != Canvas::IGNORE_ASPECT) {
|
if (swap && canvas != Canvas::IGNORE_ASPECT) {
|
||||||
// Swap input width and height when requested.
|
// Swap input width and height when requested.
|
||||||
std::swap(width, height);
|
std::swap(width, height);
|
||||||
|
if (canvas == Canvas::MAX) {
|
||||||
|
std::swap(targetWidth, targetHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double hshrink = 1.0;
|
double hshrink = 1.0;
|
||||||
|
@ -489,4 +489,28 @@ describe('Rotation', function () {
|
|||||||
.timeout({ seconds: 5 })
|
.timeout({ seconds: 5 })
|
||||||
.toBuffer()
|
.toBuffer()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it('Rotate 90 then resize with inside fit', async () => {
|
||||||
|
const data = await sharp({ create: { width: 16, height: 8, channels: 3, background: 'red' } })
|
||||||
|
.rotate(90)
|
||||||
|
.resize({ width: 6, fit: 'inside' })
|
||||||
|
.png({ compressionLevel: 0 })
|
||||||
|
.toBuffer();
|
||||||
|
|
||||||
|
const { width, height } = await sharp(data).metadata();
|
||||||
|
assert.strictEqual(width, 6);
|
||||||
|
assert.strictEqual(height, 12);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Resize with inside fit then rotate 90', async () => {
|
||||||
|
const data = await sharp({ create: { width: 16, height: 8, channels: 3, background: 'red' } })
|
||||||
|
.resize({ width: 6, fit: 'inside' })
|
||||||
|
.rotate(90)
|
||||||
|
.png({ compressionLevel: 0 })
|
||||||
|
.toBuffer();
|
||||||
|
|
||||||
|
const { width, height } = await sharp(data).metadata();
|
||||||
|
assert.strictEqual(width, 3);
|
||||||
|
assert.strictEqual(height, 6);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user