Ensure create has correct bit depth and colourspace #3139

This commit is contained in:
Lovell Fuller
2022-03-22 19:48:02 +00:00
parent b609df4b48
commit 1d36936954
6 changed files with 50 additions and 8 deletions

View File

@@ -186,6 +186,22 @@ describe('Negate', function () {
});
});
it('negate create', async () => {
const [r, g, b] = await sharp({
create: {
width: 1,
height: 1,
channels: 3,
background: { r: 10, g: 20, b: 30 }
}
})
.negate()
.raw()
.toBuffer();
assert.deepStrictEqual({ r, g, b }, { r: 245, g: 235, b: 225 });
});
it('invalid alpha value', function () {
assert.throws(function () {
sharp(fixtures.inputWebPWithTransparency).negate({ alpha: 'non-bool' });