mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add greyscale option to threshold operation (#480)
This commit is contained in:
committed by
Lovell Fuller
parent
4b98dbb454
commit
85f20c6e1b
@@ -52,8 +52,21 @@ describe('Threshold', function() {
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('threshold-128.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('threshold grayscale: true (=128)', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.threshold(128,{'grayscale':true})
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('threshold-128.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('threshold default jpeg', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
@@ -101,6 +114,18 @@ describe('Threshold', function() {
|
||||
});
|
||||
}
|
||||
|
||||
it('color threshold', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.threshold(128,{'grayscale':false})
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('threshold-color-128.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('invalid threshold -1', function() {
|
||||
assert.throws(function() {
|
||||
sharp(fixtures.inputJpg).threshold(-1);
|
||||
|
||||
Reference in New Issue
Block a user