mirror of
https://github.com/lovell/sharp.git
synced 2025-07-12 03:50:13 +02:00
Prevent bandbool creating a single channel sRGB image (#519)
This commit is contained in:
parent
ef6e90fb3c
commit
82ec2715f1
@ -396,7 +396,8 @@ namespace sharp {
|
||||
Perform boolean/bitwise operation on image color channels - results in one channel image
|
||||
*/
|
||||
VImage Bandbool(VImage image, VipsOperationBoolean const boolean) {
|
||||
return image.bandbool(boolean);
|
||||
image = image.bandbool(boolean);
|
||||
return image.copy(VImage::option()->set("interpretation", VIPS_INTERPRETATION_B_W));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -16,15 +16,26 @@ describe('Bandbool per-channel boolean operations', function() {
|
||||
sharp(fixtures.inputPngBooleanNoAlpha)
|
||||
.bandbool(op)
|
||||
.toBuffer(function(err, data, info) {
|
||||
// should use .toColourspace('b-w') here to get 1 channel output, when it is merged
|
||||
if (err) throw err;
|
||||
assert.strictEqual(200, info.width);
|
||||
assert.strictEqual(200, info.height);
|
||||
assert.strictEqual(1, info.channels);
|
||||
//assert.strictEqual(1, info.channels);
|
||||
assert.strictEqual(3, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('bandbool_' + op + '_result.png'), data, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('sRGB image retains 3 channels', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.bandbool('and')
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual(3, info.channels);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid operation', function() {
|
||||
assert.throws(function() {
|
||||
sharp().bandbool('fail');
|
||||
|
Loading…
x
Reference in New Issue
Block a user