mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Ensure keepIccProfile avoids ICC transform #4186
This commit is contained in:
parent
f7ed9b7fb6
commit
2eb03b0049
@ -29,6 +29,9 @@ Requires libvips v8.15.2
|
|||||||
[#4172](https://github.com/lovell/sharp/pull/4172)
|
[#4172](https://github.com/lovell/sharp/pull/4172)
|
||||||
[@marcosc90](https://github.com/marcosc90)
|
[@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
|
### v0.33.4 - 16th May 2024
|
||||||
|
|
||||||
* Remove experimental status from `pipelineColourspace`.
|
* Remove experimental status from `pipelineColourspace`.
|
||||||
|
@ -325,6 +325,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
if ((baton->keepMetadata & VIPS_FOREIGN_KEEP_ICC) && baton->withIccProfile.empty()) {
|
if ((baton->keepMetadata & VIPS_FOREIGN_KEEP_ICC) && baton->withIccProfile.empty()) {
|
||||||
// Cache input profile for use with output
|
// Cache input profile for use with output
|
||||||
inputProfile = sharp::GetProfile(image);
|
inputProfile = sharp::GetProfile(image);
|
||||||
|
baton->input->ignoreIcc = true;
|
||||||
}
|
}
|
||||||
char const *processingProfile = image.interpretation() == VIPS_INTERPRETATION_RGB16 ? "p3" : "srgb";
|
char const *processingProfile = image.interpretation() == VIPS_INTERPRETATION_RGB16 ? "p3" : "srgb";
|
||||||
if (
|
if (
|
||||||
|
1
test/fixtures/index.js
vendored
1
test/fixtures/index.js
vendored
@ -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
|
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
|
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/
|
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
|
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
|
inputWebPWithTransparency: getPath('5_webp_a.webp'), // http://www.gstatic.com/webp/gallery3/5_webp_a.webp
|
||||||
|
BIN
test/fixtures/prophoto.png
vendored
Normal file
BIN
test/fixtures/prophoto.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 556 B |
@ -601,6 +601,17 @@ describe('Image metadata', function () {
|
|||||||
assert.strictEqual(description, 'Generic RGB Profile');
|
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 () => {
|
it('keep existing CMYK ICC profile', async () => {
|
||||||
const data = await sharp(fixtures.inputJpgWithCmykProfile)
|
const data = await sharp(fixtures.inputJpgWithCmykProfile)
|
||||||
.pipelineColourspace('cmyk')
|
.pipelineColourspace('cmyk')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user