Ensure ICC transform of withMetadata output #133

This commit is contained in:
Lovell Fuller 2014-12-04 11:28:09 +00:00
parent 940b6f505f
commit a56102a209
2 changed files with 5 additions and 4 deletions

View File

@ -403,7 +403,7 @@ Use progressive (interlace) scan for JPEG and PNG output. This typically reduces
#### withMetadata() #### 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. The default behaviour is to strip all metadata and convert to the device-independent sRGB colour space.

View File

@ -115,6 +115,9 @@ class ResizeWorker : public NanAsyncWorker {
// Increment processing task counter // Increment processing task counter
g_atomic_int_inc(&counterProcess); 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 // Hang image references from this hook object
VipsObject *hook = reinterpret_cast<VipsObject*>(vips_image_new()); 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 // Ensure we're using a device-independent colour space
if (HasProfile(image)) { if (HasProfile(image)) {
// Convert to sRGB using embedded profile // Convert to sRGB using embedded profile
std::string srgbProfile = baton->iccProfilePath + "sRGB_IEC61966-2-1_black_scaled.icc";
VipsImage *transformed; VipsImage *transformed;
if (!vips_icc_transform(image, &transformed, srgbProfile.c_str(), "embedded", TRUE, NULL)) { if (!vips_icc_transform(image, &transformed, srgbProfile.c_str(), "embedded", TRUE, NULL)) {
// Embedded profile can fail, so only update references on success // 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) { } else if (image->Type == VIPS_INTERPRETATION_CMYK) {
// Convert to sRGB using default "USWebCoatedSWOP" CMYK profile // 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"; std::string cmykProfile = baton->iccProfilePath + "USWebCoatedSWOP.icc";
VipsImage *transformed; VipsImage *transformed;
if (vips_icc_transform(image, &transformed, srgbProfile.c_str(), "input_profile", cmykProfile.c_str(), NULL)) { 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; VipsImage *rgb;
if (baton->withMetadata && HasProfile(image)) { if (baton->withMetadata && HasProfile(image)) {
// Convert to device-dependent RGB using embedded profile of input // 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); return Error(baton, hook);
} }
} else { } else {