mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Ensure embedded ICC profiles output with perceptual intent #321
This commit is contained in:
parent
16e0d54b15
commit
58e6368525
@ -421,7 +421,10 @@ class PipelineWorker : public AsyncWorker {
|
||||
if (HasProfile(image)) {
|
||||
// Convert to sRGB using embedded profile
|
||||
VipsImage *transformed;
|
||||
if (!vips_icc_transform(image, &transformed, srgbProfile.data(), "embedded", TRUE, nullptr)) {
|
||||
if (
|
||||
!vips_icc_transform(image, &transformed, srgbProfile.data(),
|
||||
"embedded", TRUE, "intent", VIPS_INTENT_PERCEPTUAL, nullptr)
|
||||
) {
|
||||
// Embedded profile can fail, so only update references on success
|
||||
vips_object_local(hook, transformed);
|
||||
image = transformed;
|
||||
@ -430,7 +433,10 @@ class PipelineWorker : public AsyncWorker {
|
||||
// Convert to sRGB using default "USWebCoatedSWOP" CMYK profile
|
||||
std::string cmykProfile = baton->iccProfilePath + "USWebCoatedSWOP.icc";
|
||||
VipsImage *transformed;
|
||||
if (vips_icc_transform(image, &transformed, srgbProfile.data(), "input_profile", cmykProfile.data(), nullptr)) {
|
||||
if (
|
||||
vips_icc_transform(image, &transformed, srgbProfile.data(),
|
||||
"input_profile", cmykProfile.data(), "intent", VIPS_INTENT_PERCEPTUAL, nullptr)
|
||||
) {
|
||||
return Error();
|
||||
}
|
||||
vips_object_local(hook, transformed);
|
||||
|
BIN
test/fixtures/expected/colourspace.cmyk-without-profile.jpg
vendored
Normal file
BIN
test/fixtures/expected/colourspace.cmyk-without-profile.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
test/fixtures/expected/colourspace.cmyk.jpg
vendored
Normal file
BIN
test/fixtures/expected/colourspace.cmyk.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@ -61,12 +61,12 @@ describe('Colour space conversion', function() {
|
||||
.resize(320, 240)
|
||||
.background('white')
|
||||
.embed()
|
||||
.toFile(fixtures.path('output.cmyk2srgb.jpg'), function(err, info) {
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
done();
|
||||
fixtures.assertSimilar(fixtures.expected('colourspace.cmyk.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
@ -75,10 +75,9 @@ describe('Colour space conversion', function() {
|
||||
.resize(320)
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
done();
|
||||
fixtures.assertSimilar(fixtures.expected('colourspace.cmyk-without-profile.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user