mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Import embedded colour profile, if present #99
This commit is contained in:
parent
46f229e308
commit
37cb4339e2
11
src/sharp.cc
11
src/sharp.cc
@ -511,6 +511,17 @@ class ResizeWorker : public NanAsyncWorker {
|
|||||||
image = shrunk_on_load;
|
image = shrunk_on_load;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Import embedded colour profile, if present
|
||||||
|
if (vips_image_get_typeof(image, VIPS_META_ICC_NAME)) {
|
||||||
|
VipsImage *profile = vips_image_new();
|
||||||
|
vips_object_local(hook, profile);
|
||||||
|
if (vips_icc_import(image, &profile, NULL, "embedded", TRUE, "pcs", VIPS_PCS_XYZ, NULL)) {
|
||||||
|
return resize_error(baton, hook);
|
||||||
|
}
|
||||||
|
g_object_unref(image);
|
||||||
|
image = profile;
|
||||||
|
}
|
||||||
|
|
||||||
// Flatten image to remove alpha channel
|
// Flatten image to remove alpha channel
|
||||||
if (baton->flatten && sharp_image_has_alpha(image)) {
|
if (baton->flatten && sharp_image_has_alpha(image)) {
|
||||||
// Background colour
|
// Background colour
|
||||||
|
BIN
tests/fixtures/Channel_digital_image_CMYK_color.jpg
vendored
Normal file
BIN
tests/fixtures/Channel_digital_image_CMYK_color.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 714 KiB |
@ -13,6 +13,7 @@ var fixturesPath = path.join(__dirname, 'fixtures');
|
|||||||
var inputJpg = path.join(fixturesPath, '2569067123_aca715a2ee_o.jpg'); // http://www.flickr.com/photos/grizdave/2569067123/
|
var inputJpg = path.join(fixturesPath, '2569067123_aca715a2ee_o.jpg'); // http://www.flickr.com/photos/grizdave/2569067123/
|
||||||
var inputJpgWithExif = path.join(fixturesPath, 'Landscape_8.jpg'); // https://github.com/recurser/exif-orientation-examples/blob/master/Landscape_8.jpg
|
var inputJpgWithExif = path.join(fixturesPath, 'Landscape_8.jpg'); // https://github.com/recurser/exif-orientation-examples/blob/master/Landscape_8.jpg
|
||||||
var inputJpgWithGammaHoliness = path.join(fixturesPath, 'gamma_dalai_lama_gray.jpg'); // http://www.4p8.com/eric.brasseur/gamma.html
|
var inputJpgWithGammaHoliness = path.join(fixturesPath, 'gamma_dalai_lama_gray.jpg'); // http://www.4p8.com/eric.brasseur/gamma.html
|
||||||
|
var inputJpgWithCmykProfile = path.join(fixturesPath, 'Channel_digital_image_CMYK_color.jpg'); // http://en.wikipedia.org/wiki/File:Channel_digital_image_CMYK_color.jpg
|
||||||
|
|
||||||
var inputPng = path.join(fixturesPath, '50020484-00001.png'); // http://c.searspartsdirect.com/lis_png/PLDM/50020484-00001.png
|
var inputPng = path.join(fixturesPath, '50020484-00001.png'); // http://c.searspartsdirect.com/lis_png/PLDM/50020484-00001.png
|
||||||
var inputPngWithTransparency = path.join(fixturesPath, 'blackbug.png'); // public domain
|
var inputPngWithTransparency = path.join(fixturesPath, 'blackbug.png'); // public domain
|
||||||
@ -316,6 +317,16 @@ async.series([
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// Check colour space conversion from CMYK to sRGB
|
||||||
|
function(done) {
|
||||||
|
sharp(inputJpgWithCmykProfile).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();
|
||||||
|
});
|
||||||
|
},
|
||||||
// Interpolation: nearest neighbour
|
// Interpolation: nearest neighbour
|
||||||
function(done) {
|
function(done) {
|
||||||
sharp(inputJpg).resize(320, 240).interpolateWith(sharp.interpolator.nearest).toBuffer(function(err, data, info) {
|
sharp(inputJpg).resize(320, 240).interpolateWith(sharp.interpolator.nearest).toBuffer(function(err, data, info) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user