From 5f8646d93779ae802a4f5e5a47ea1c60e817d9a4 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Mon, 17 Apr 2023 19:53:48 +0100 Subject: [PATCH] Support modulate op with non-sRGB pipeline colourspace #3620 --- docs/changelog.md | 3 +++ src/operations.cc | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 2665bef9..662da39b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -23,6 +23,9 @@ Requires libvips v8.14.2 * Ensure profile-less CMYK to CMYK roundtrip skips colourspace conversion. [#3620](https://github.com/lovell/sharp/issues/3620) +* Add support for `modulate` operation when using non-sRGB pipeline colourspace. + [#3620](https://github.com/lovell/sharp/issues/3620) + ### v0.32.0 - 24th March 2023 * Default to using sequential rather than random access read where possible. diff --git a/src/operations.cc b/src/operations.cc index 5f421940..a3b480a5 100644 --- a/src/operations.cc +++ b/src/operations.cc @@ -186,6 +186,7 @@ namespace sharp { VImage Modulate(VImage image, double const brightness, double const saturation, int const hue, double const lightness) { + VipsInterpretation colourspaceBeforeModulate = image.interpretation(); if (HasAlpha(image)) { // Separate alpha channel VImage alpha = image[image.bands() - 1]; @@ -195,7 +196,7 @@ namespace sharp { { brightness, saturation, 1}, { lightness, 0.0, static_cast(hue) } ) - .colourspace(VIPS_INTERPRETATION_sRGB) + .colourspace(colourspaceBeforeModulate) .bandjoin(alpha); } else { return image @@ -204,7 +205,7 @@ namespace sharp { { brightness, saturation, 1 }, { lightness, 0.0, static_cast(hue) } ) - .colourspace(VIPS_INTERPRETATION_sRGB); + .colourspace(colourspaceBeforeModulate); } }