diff --git a/src/pipeline.cc b/src/pipeline.cc index 53441f92..1558b425 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -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); diff --git a/test/fixtures/expected/colourspace.cmyk-without-profile.jpg b/test/fixtures/expected/colourspace.cmyk-without-profile.jpg new file mode 100644 index 00000000..8959e692 Binary files /dev/null and b/test/fixtures/expected/colourspace.cmyk-without-profile.jpg differ diff --git a/test/fixtures/expected/colourspace.cmyk.jpg b/test/fixtures/expected/colourspace.cmyk.jpg new file mode 100644 index 00000000..d5b92ca3 Binary files /dev/null and b/test/fixtures/expected/colourspace.cmyk.jpg differ diff --git a/test/unit/colourspace.js b/test/unit/colourspace.js index 8f878ac0..5b2de725 100644 --- a/test/unit/colourspace.js +++ b/test/unit/colourspace.js @@ -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); }); });