Ensure embedded ICC profiles output with perceptual intent #321

This commit is contained in:
Lovell Fuller 2015-12-06 20:24:17 +00:00
parent 16e0d54b15
commit 58e6368525
4 changed files with 11 additions and 6 deletions

View File

@ -421,7 +421,10 @@ class PipelineWorker : public AsyncWorker {
if (HasProfile(image)) { if (HasProfile(image)) {
// Convert to sRGB using embedded profile // Convert to sRGB using embedded profile
VipsImage *transformed; 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 // Embedded profile can fail, so only update references on success
vips_object_local(hook, transformed); vips_object_local(hook, transformed);
image = transformed; image = transformed;
@ -430,7 +433,10 @@ class PipelineWorker : public AsyncWorker {
// Convert to sRGB using default "USWebCoatedSWOP" CMYK profile // Convert to sRGB using default "USWebCoatedSWOP" CMYK profile
std::string cmykProfile = baton->iccProfilePath + "USWebCoatedSWOP.icc"; std::string cmykProfile = baton->iccProfilePath + "USWebCoatedSWOP.icc";
VipsImage *transformed; 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(); return Error();
} }
vips_object_local(hook, transformed); vips_object_local(hook, transformed);

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -61,12 +61,12 @@ describe('Colour space conversion', function() {
.resize(320, 240) .resize(320, 240)
.background('white') .background('white')
.embed() .embed()
.toFile(fixtures.path('output.cmyk2srgb.jpg'), function(err, info) { .toBuffer(function(err, data, info) {
if (err) throw err; if (err) throw err;
assert.strictEqual('jpeg', info.format); assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height); 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) .resize(320)
.toBuffer(function(err, data, info) { .toBuffer(function(err, data, info) {
if (err) throw err; if (err) throw err;
assert.strictEqual(true, data.length > 0);
assert.strictEqual('jpeg', info.format); assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
done(); fixtures.assertSimilar(fixtures.expected('colourspace.cmyk-without-profile.jpg'), data, done);
}); });
}); });