mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Ensure composite can tile with outside resize #3227
This commit is contained in:
parent
4d82331bf6
commit
a75718565c
@ -4,6 +4,11 @@
|
|||||||
|
|
||||||
Requires libvips v8.12.2
|
Requires libvips v8.12.2
|
||||||
|
|
||||||
|
### v0.30.7 - TBD
|
||||||
|
|
||||||
|
* Ensure tiled composition always works with outside resizing.
|
||||||
|
[#3227](https://github.com/lovell/sharp/issues/3227)
|
||||||
|
|
||||||
### v0.30.6 - 30th May 2022
|
### v0.30.6 - 30th May 2022
|
||||||
|
|
||||||
* Allow values for `limitInputPixels` larger than 32-bit.
|
* Allow values for `limitInputPixels` larger than 32-bit.
|
||||||
|
@ -607,14 +607,14 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
int across = 0;
|
int across = 0;
|
||||||
int down = 0;
|
int down = 0;
|
||||||
// Use gravity in overlay
|
// Use gravity in overlay
|
||||||
if (compositeImage.width() <= baton->width) {
|
if (compositeImage.width() <= image.width()) {
|
||||||
across = static_cast<int>(ceil(static_cast<double>(image.width()) / compositeImage.width()));
|
across = static_cast<int>(ceil(static_cast<double>(image.width()) / compositeImage.width()));
|
||||||
// Ensure odd number of tiles across when gravity is centre, north or south
|
// Ensure odd number of tiles across when gravity is centre, north or south
|
||||||
if (composite->gravity == 0 || composite->gravity == 1 || composite->gravity == 3) {
|
if (composite->gravity == 0 || composite->gravity == 1 || composite->gravity == 3) {
|
||||||
across |= 1;
|
across |= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (compositeImage.height() <= baton->height) {
|
if (compositeImage.height() <= image.height()) {
|
||||||
down = static_cast<int>(ceil(static_cast<double>(image.height()) / compositeImage.height()));
|
down = static_cast<int>(ceil(static_cast<double>(image.height()) / compositeImage.height()));
|
||||||
// Ensure odd number of tiles down when gravity is centre, east or west
|
// Ensure odd number of tiles down when gravity is centre, east or west
|
||||||
if (composite->gravity == 0 || composite->gravity == 2 || composite->gravity == 4) {
|
if (composite->gravity == 0 || composite->gravity == 2 || composite->gravity == 4) {
|
||||||
|
@ -420,4 +420,31 @@ describe('composite', () => {
|
|||||||
|
|
||||||
assert.deepStrictEqual(red, { r, g, b });
|
assert.deepStrictEqual(red, { r, g, b });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Ensure tiled composition works with resized fit=outside', async () => {
|
||||||
|
const { info } = await sharp({
|
||||||
|
create: {
|
||||||
|
width: 41, height: 41, channels: 3, background: 'red'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.resize({
|
||||||
|
width: 10,
|
||||||
|
height: 40,
|
||||||
|
fit: 'outside'
|
||||||
|
})
|
||||||
|
.composite([
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
create: {
|
||||||
|
width: 16, height: 16, channels: 3, background: 'green'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tile: true
|
||||||
|
}
|
||||||
|
])
|
||||||
|
.toBuffer({ resolveWithObject: true });
|
||||||
|
|
||||||
|
assert.strictEqual(info.width, 40);
|
||||||
|
assert.strictEqual(info.height, 40);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user