Add support to recomb operation for 4x4 matrices

This commit is contained in:
Denice
2024-07-02 17:06:26 +07:00
committed by Lovell Fuller
parent eab7dc1b49
commit 60c5c5083d
14 changed files with 74 additions and 34 deletions

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -139,6 +139,7 @@ module.exports = {
testPattern: getPath('test-pattern.png'),
inputPngWithTransparent: getPath('d.png'),
// Path for tests requiring human inspection
path: getPath,

View File

@@ -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 })

View File

@@ -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 () {