mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure create has correct bit depth and colourspace #3139
This commit is contained in:
@@ -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' });
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('Gaussian noise', function () {
|
||||
sigma: 30
|
||||
}
|
||||
}
|
||||
});
|
||||
}).toColourspace('b-w');
|
||||
noise.toFile(output, function (err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
@@ -131,6 +131,7 @@ describe('Gaussian noise', function () {
|
||||
}
|
||||
});
|
||||
noise
|
||||
.toColourspace('b-w')
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(1, info.channels);
|
||||
|
||||
Reference in New Issue
Block a user