mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add named 'alpha' channel to extractChannel op #2138
This commit is contained in:
BIN
test/fixtures/expected/extract-alpha-2-channel.png
vendored
Normal file
BIN
test/fixtures/expected/extract-alpha-2-channel.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
@@ -80,6 +80,19 @@ describe('Image channel extraction', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Alpha from 2-channel input', function (done) {
|
||||
const output = fixtures.path('output.extract-alpha-2-channel.png');
|
||||
sharp(fixtures.inputPngWithGreyAlpha)
|
||||
.extractChannel('alpha')
|
||||
.toColourspace('b-w')
|
||||
.toFile(output, function (err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(1, info.channels);
|
||||
fixtures.assertMaxColourDistance(output, fixtures.expected('extract-alpha-2-channel.png'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid channel number', function () {
|
||||
assert.throws(function () {
|
||||
sharp(fixtures.inputJpg)
|
||||
|
||||
Reference in New Issue
Block a user