mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Ensure ICC transform of withMetadata output #133
This commit is contained in:
parent
940b6f505f
commit
a56102a209
@ -403,7 +403,7 @@ Use progressive (interlace) scan for JPEG and PNG output. This typically reduces
|
||||
|
||||
#### withMetadata()
|
||||
|
||||
Include all metadata (ICC, EXIF, XMP) from the input image in the output image.
|
||||
Include all metadata (EXIF, XMP, IPTC) from the input image in the output image. This will also convert to and add the latest web-friendly v2 sRGB ICC profile.
|
||||
|
||||
The default behaviour is to strip all metadata and convert to the device-independent sRGB colour space.
|
||||
|
||||
|
@ -115,6 +115,9 @@ class ResizeWorker : public NanAsyncWorker {
|
||||
// Increment processing task counter
|
||||
g_atomic_int_inc(&counterProcess);
|
||||
|
||||
// Latest v2 sRGB ICC profile
|
||||
std::string srgbProfile = baton->iccProfilePath + "sRGB_IEC61966-2-1_black_scaled.icc";
|
||||
|
||||
// Hang image references from this hook object
|
||||
VipsObject *hook = reinterpret_cast<VipsObject*>(vips_image_new());
|
||||
|
||||
@ -272,7 +275,6 @@ class ResizeWorker : public NanAsyncWorker {
|
||||
// Ensure we're using a device-independent colour space
|
||||
if (HasProfile(image)) {
|
||||
// Convert to sRGB using embedded profile
|
||||
std::string srgbProfile = baton->iccProfilePath + "sRGB_IEC61966-2-1_black_scaled.icc";
|
||||
VipsImage *transformed;
|
||||
if (!vips_icc_transform(image, &transformed, srgbProfile.c_str(), "embedded", TRUE, NULL)) {
|
||||
// Embedded profile can fail, so only update references on success
|
||||
@ -281,7 +283,6 @@ class ResizeWorker : public NanAsyncWorker {
|
||||
}
|
||||
} else if (image->Type == VIPS_INTERPRETATION_CMYK) {
|
||||
// Convert to sRGB using default "USWebCoatedSWOP" CMYK profile
|
||||
std::string srgbProfile = baton->iccProfilePath + "sRGB_IEC61966-2-1_black_scaled.icc";
|
||||
std::string cmykProfile = baton->iccProfilePath + "USWebCoatedSWOP.icc";
|
||||
VipsImage *transformed;
|
||||
if (vips_icc_transform(image, &transformed, srgbProfile.c_str(), "input_profile", cmykProfile.c_str(), NULL)) {
|
||||
@ -576,7 +577,7 @@ class ResizeWorker : public NanAsyncWorker {
|
||||
VipsImage *rgb;
|
||||
if (baton->withMetadata && HasProfile(image)) {
|
||||
// Convert to device-dependent RGB using embedded profile of input
|
||||
if (vips_icc_export(image, &rgb, NULL)) {
|
||||
if (vips_icc_transform(image, &rgb, srgbProfile.c_str(), "embedded", TRUE, NULL)) {
|
||||
return Error(baton, hook);
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user