mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add support to recomb operation for 4x4 matrices
This commit is contained in:
BIN
test/fixtures/d.png
vendored
Normal file
BIN
test/fixtures/d.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
BIN
test/fixtures/expected/d-opacity-30.png
vendored
Normal file
BIN
test/fixtures/expected/d-opacity-30.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
1
test/fixtures/index.js
vendored
1
test/fixtures/index.js
vendored
@@ -139,6 +139,7 @@ module.exports = {
|
||||
|
||||
testPattern: getPath('test-pattern.png'),
|
||||
|
||||
inputPngWithTransparent: getPath('d.png'),
|
||||
// Path for tests requiring human inspection
|
||||
path: getPath,
|
||||
|
||||
|
||||
@@ -295,6 +295,13 @@ sharp('input.gif')
|
||||
[0.2392, 0.4696, 0.0912],
|
||||
])
|
||||
|
||||
.recomb([
|
||||
[1,0,0,0],
|
||||
[0,1,0,0],
|
||||
[0,0,1,0],
|
||||
[0,0,0,1],
|
||||
])
|
||||
|
||||
.modulate({ brightness: 2 })
|
||||
.modulate({ hue: 180 })
|
||||
.modulate({ lightness: 10 })
|
||||
|
||||
@@ -121,6 +121,29 @@ describe('Recomb', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('applies opacity 30% to the image', function (done) {
|
||||
const output = fixtures.path('output.recomb-opacity.png');
|
||||
sharp(fixtures.inputPngWithTransparent)
|
||||
.recomb([
|
||||
[1, 0, 0, 0],
|
||||
[0, 1, 0, 0],
|
||||
[0, 0, 1, 0],
|
||||
[0, 0, 0, 0.3]
|
||||
])
|
||||
.toFile(output, function (err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(48, info.width);
|
||||
assert.strictEqual(48, info.height);
|
||||
fixtures.assertMaxColourDistance(
|
||||
output,
|
||||
fixtures.expected('d-opacity-30.png'),
|
||||
17
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('invalid matrix specification', function () {
|
||||
it('missing', function () {
|
||||
assert.throws(function () {
|
||||
|
||||
Reference in New Issue
Block a user