Add pipelineColourspace operator

This commit is contained in:
Daiz
2021-05-08 12:58:52 +03:00
committed by Lovell Fuller
parent 536412515f
commit bb48d0d857
10 changed files with 133 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
test/fixtures/gradients-rgb8.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 KiB

View File

@@ -74,6 +74,7 @@ module.exports = {
inputJpgLossless: getPath('testimgl.jpg'), // Lossless JPEG from ftp://ftp.fu-berlin.de/unix/X11/graphics/ImageMagick/delegates/ljpeg-6b.tar.gz
inputPng: getPath('50020484-00001.png'), // http://c.searspartsdirect.com/lis_png/PLDM/50020484-00001.png
inputPngGradients: getPath('gradients-rgb8.png'),
inputPngWithTransparency: getPath('blackbug.png'), // public domain
inputPngCompleteTransparency: getPath('full-transparent.png'),
inputPngWithGreyAlpha: getPath('grey-8bit-alpha.png'),

View File

@@ -90,7 +90,29 @@ describe('Colour space conversion', function () {
});
});
it('Invalid input', function () {
it('From sRGB with RGB16 pipeline, resize with gamma, to sRGB', function (done) {
sharp(fixtures.inputPngGradients)
.pipelineColourspace('rgb16')
.resize(320)
.gamma()
.toColourspace('srgb')
.toBuffer(function (err, data, info) {
if (err) throw err;
assert.strictEqual(320, info.width);
fixtures.assertSimilar(fixtures.expected('colourspace-gradients-gamma-resize.png'), data, {
threshold: 0
}, done);
});
});
it('Invalid pipelineColourspace input', function () {
assert.throws(function () {
sharp(fixtures.inputJpg)
.pipelineColorspace(null);
}, /Expected string for colourspace but received null of type object/);
});
it('Invalid toColourspace input', function () {
assert.throws(function () {
sharp(fixtures.inputJpg)
.toColourspace(null);