diff --git a/docs/changelog.md b/docs/changelog.md
index 256c213a..886b4936 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -14,6 +14,9 @@ Requires libvips v8.8.1.
[#1952](https://github.com/lovell/sharp/pull/1952)
[@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 - 28th October 2019
* Add `background` option to tile output operation.
diff --git a/src/operations.cc b/src/operations.cc
index ea2732ba..9f722971 100644
--- a/src/operations.cc
+++ b/src/operations.cc
@@ -191,12 +191,20 @@ namespace sharp {
VImage alpha = image[image.bands() - 1];
return RemoveAlpha(image)
.colourspace(VIPS_INTERPRETATION_LCH)
- .linear({brightness, saturation, 1}, {0, 0, static_cast(hue)})
+ .linear(
+ { brightness, saturation, 1},
+ { 0.0, 0.0, static_cast(hue) }
+ )
+ .colourspace(VIPS_INTERPRETATION_sRGB)
.bandjoin(alpha);
} else {
return image
.colourspace(VIPS_INTERPRETATION_LCH)
- .linear({brightness, saturation, 1}, {0, 0, static_cast(hue)});
+ .linear(
+ { brightness, saturation, 1 },
+ { 0.0, 0.0, static_cast(hue) }
+ )
+ .colourspace(VIPS_INTERPRETATION_sRGB);
}
}
diff --git a/test/fixtures/expected/modulate-linear.jpg b/test/fixtures/expected/modulate-linear.jpg
new file mode 100644
index 00000000..bd7899fa
Binary files /dev/null and b/test/fixtures/expected/modulate-linear.jpg differ
diff --git a/test/unit/modulate.js b/test/unit/modulate.js
index b5f2ee62..c187b48a 100644
--- a/test/unit/modulate.js
+++ b/test/unit/modulate.js
@@ -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);
+ });
+ });
});