Skip to content

Commit

Permalink
Support modulate op with non-sRGB pipeline colourspace #3620
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Apr 17, 2023
1 parent b763801 commit 5f8646d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions src/operations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -195,7 +196,7 @@ namespace sharp {
{ brightness, saturation, 1},
{ lightness, 0.0, static_cast<double>(hue) }
)
.colourspace(VIPS_INTERPRETATION_sRGB)
.colourspace(colourspaceBeforeModulate)
.bandjoin(alpha);
} else {
return image
Expand All @@ -204,7 +205,7 @@ namespace sharp {
{ brightness, saturation, 1 },
{ lightness, 0.0, static_cast<double>(hue) }
)
.colourspace(VIPS_INTERPRETATION_sRGB);
.colourspace(colourspaceBeforeModulate);
}
}

Expand Down

0 comments on commit 5f8646d

Please sign in to comment.