Ensure modulate can co-exist with other colour ops #1958

This commit is contained in:
Lovell Fuller 2019-11-11 22:16:28 +00:00
parent ff98d2e44a
commit 833aaead56
4 changed files with 30 additions and 2 deletions

View File

@ -14,6 +14,9 @@ Requires libvips v8.8.1.
[#1952](https://github.com/lovell/sharp/pull/1952) [#1952](https://github.com/lovell/sharp/pull/1952)
[@pouya-eghbali](https://github.com/pouya-eghbali) [@pouya-eghbali](https://github.com/pouya-eghbali)
* Ensure `modulate` and other colour-based operations can co-exist.
[#1958](https://github.com/lovell/sharp/issues/1958)
#### v0.23.2 - 28<sup>th</sup> October 2019 #### v0.23.2 - 28<sup>th</sup> October 2019
* Add `background` option to tile output operation. * Add `background` option to tile output operation.

View File

@ -191,12 +191,20 @@ namespace sharp {
VImage alpha = image[image.bands() - 1]; VImage alpha = image[image.bands() - 1];
return RemoveAlpha(image) return RemoveAlpha(image)
.colourspace(VIPS_INTERPRETATION_LCH) .colourspace(VIPS_INTERPRETATION_LCH)
.linear({brightness, saturation, 1}, {0, 0, static_cast<double>(hue)}) .linear(
{ brightness, saturation, 1},
{ 0.0, 0.0, static_cast<double>(hue) }
)
.colourspace(VIPS_INTERPRETATION_sRGB)
.bandjoin(alpha); .bandjoin(alpha);
} else { } else {
return image return image
.colourspace(VIPS_INTERPRETATION_LCH) .colourspace(VIPS_INTERPRETATION_LCH)
.linear({brightness, saturation, 1}, {0, 0, static_cast<double>(hue)}); .linear(
{ brightness, saturation, 1 },
{ 0.0, 0.0, static_cast<double>(hue) }
)
.colourspace(VIPS_INTERPRETATION_sRGB);
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

View File

@ -122,4 +122,21 @@ describe('Modulate', function () {
}); });
}); });
}); });
it('should be able to use linear and modulate together', function () {
const base = 'modulate-linear.jpg';
const actual = fixtures.path('output.' + base);
const expected = fixtures.expected(base);
const contrast = 1.5;
const brightness = 0.5;
return sharp(fixtures.testPattern)
.linear(contrast, -(128 * contrast) + 128)
.modulate({ brightness })
.toFile(actual)
.then(function () {
fixtures.assertMaxColourDistance(actual, expected);
});
});
}); });