forked from lovell/sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbandbool.js
More file actions
49 lines (44 loc) · 1.26 KB
/
Copy pathbandbool.js
File metadata and controls
49 lines (44 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
const assert = require('assert');
const fixtures = require('../fixtures');
const sharp = require('../../');
describe('Bandbool per-channel boolean operations', function () {
[
sharp.bool.and,
sharp.bool.or,
sharp.bool.eor
]
.forEach(function (op) {
it(op + ' operation', function (done) {
sharp(fixtures.inputPngBooleanNoAlpha)
.bandbool(op)
.toColourspace('b-w')
.toBuffer(function (err, data, info) {
if (err) throw err;
assert.strictEqual(200, info.width);
assert.strictEqual(200, info.height);
assert.strictEqual(1, 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) {
if (err) throw err;
assert.strictEqual(3, info.channels);
done();
});
});
it('Invalid operation', function () {
assert.throws(function () {
sharp().bandbool('fail');
});
});
it('Missing operation', function () {
assert.throws(function () {
sharp().bandbool();
});
});
});