Skip to content

Commit

Permalink
Ensure keepIccProfile avoids ICC transform #4186
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Aug 11, 2024
1 parent f7ed9b7 commit 2eb03b0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Requires libvips v8.15.2
[#4172](https://github.com/lovell/sharp/pull/4172)
[@marcosc90](https://github.com/marcosc90)

* Ensure `keepIccProfile` avoids colour transformation where possible.
[#4186](https://github.com/lovell/sharp/issues/4186)

### v0.33.4 - 16th May 2024

* Remove experimental status from `pipelineColourspace`.
Expand Down
1 change: 1 addition & 0 deletions src/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ class PipelineWorker : public Napi::AsyncWorker {
if ((baton->keepMetadata & VIPS_FOREIGN_KEEP_ICC) && baton->withIccProfile.empty()) {
// Cache input profile for use with output
inputProfile = sharp::GetProfile(image);
baton->input->ignoreIcc = true;
}
char const *processingProfile = image.interpretation() == VIPS_INTERPRETATION_RGB16 ? "p3" : "srgb";
if (
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ module.exports = {
inputPngTrimSpecificColour16bit: getPath('Flag_of_the_Netherlands-16bit.png'), // convert Flag_of_the_Netherlands.png -depth 16 Flag_of_the_Netherlands-16bit.png
inputPngTrimSpecificColourIncludeAlpha: getPath('Flag_of_the_Netherlands-alpha.png'), // convert Flag_of_the_Netherlands.png -alpha set -background none -channel A -evaluate multiply 0.5 +channel Flag_of_the_Netherlands-alpha.png
inputPngUint32Limit: getPath('65536-uint32-limit.png'), // https://alexandre.alapetite.fr/doc-alex/large-image/
inputPngWithProPhotoProfile: getPath('prophoto.png'),

inputWebP: getPath('4.webp'), // http://www.gstatic.com/webp/gallery/4.webp
inputWebPWithTransparency: getPath('5_webp_a.webp'), // http://www.gstatic.com/webp/gallery3/5_webp_a.webp
Expand Down
Binary file added test/fixtures/prophoto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions test/unit/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,17 @@ describe('Image metadata', function () {
assert.strictEqual(description, 'Generic RGB Profile');
});

it('keep existing ICC profile, avoid colour transform', async () => {
const [r, g, b] = await sharp(fixtures.inputPngWithProPhotoProfile)
.keepIccProfile()
.raw()
.toBuffer();

assert.strictEqual(r, 131);
assert.strictEqual(g, 141);
assert.strictEqual(b, 192);
});

it('keep existing CMYK ICC profile', async () => {
const data = await sharp(fixtures.inputJpgWithCmykProfile)
.pipelineColourspace('cmyk')
Expand Down

0 comments on commit 2eb03b0

Please sign in to comment.