mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add ensureAlpha op, adds alpha channel if missing #1153
This commit is contained in:
@@ -115,6 +115,7 @@ describe('Alpha transparency', function () {
|
||||
fixtures.inputWebP
|
||||
].map(function (input) {
|
||||
return sharp(input)
|
||||
.resize(10)
|
||||
.removeAlpha()
|
||||
.toBuffer({ resolveWithObject: true })
|
||||
.then(function (result) {
|
||||
@@ -122,4 +123,24 @@ describe('Alpha transparency', function () {
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('Ensures alpha from fixtures without transparency, ignores those with', function () {
|
||||
return Promise.all([
|
||||
fixtures.inputPngWithTransparency,
|
||||
fixtures.inputPngWithTransparency16bit,
|
||||
fixtures.inputWebPWithTransparency,
|
||||
fixtures.inputJpg,
|
||||
fixtures.inputPng,
|
||||
fixtures.inputWebP
|
||||
].map(function (input) {
|
||||
return sharp(input)
|
||||
.resize(10)
|
||||
.ensureAlpha()
|
||||
.png()
|
||||
.toBuffer({ resolveWithObject: true })
|
||||
.then(function (result) {
|
||||
assert.strictEqual(4, result.info.channels);
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user