mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Fix erroneous top/left clipping in composite #2571
Fixes bug where certain input values for top/left parameters in composite can conflict with clipping logic, resulting in inaccurate alignment in output.
This commit is contained in:
@@ -408,4 +408,20 @@ describe('composite', () => {
|
||||
}, /Expected valid gravity for gravity but received invalid of type string/);
|
||||
});
|
||||
});
|
||||
|
||||
it('Allow offset beyond bottom/right edge', async () => {
|
||||
const red = { r: 255, g: 0, b: 0 };
|
||||
const blue = { r: 0, g: 0, b: 255 };
|
||||
|
||||
const [r, g, b] = await sharp({ create: { width: 2, height: 2, channels: 4, background: red } })
|
||||
.composite([{
|
||||
input: { create: { width: 2, height: 2, channels: 4, background: blue } },
|
||||
top: 1,
|
||||
left: 1
|
||||
}])
|
||||
.raw()
|
||||
.toBuffer();
|
||||
|
||||
assert.deepStrictEqual(red, { r, g, b });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user