diff --git a/icc/sRGB_IEC61966-2-1_black_scaled.icc b/icc/sRGB_IEC61966-2-1_black_scaled.icc new file mode 100644 index 00000000..71e33830 Binary files /dev/null and b/icc/sRGB_IEC61966-2-1_black_scaled.icc differ diff --git a/index.js b/index.js index 125c0ea9..58a7e4f7 100755 --- a/index.js +++ b/index.js @@ -20,8 +20,8 @@ var Sharp = function(input) { // input options streamIn: false, sequentialRead: false, - // ICC profile to use when input CMYK image has no embedded profile - iccProfileCmyk: path.join(__dirname, 'icc', 'USWebCoatedSWOP.icc'), + // ICC profiles + iccProfilePath: path.join(__dirname, 'icc') + path.sep, // resize options topOffsetPre: -1, leftOffsetPre: -1, diff --git a/preinstall.sh b/preinstall.sh index ebf29cea..3325f298 100755 --- a/preinstall.sh +++ b/preinstall.sh @@ -94,7 +94,7 @@ case $(uname -s) in trusty|utopic|qiana|rebecca) # Ubuntu 14, Mint 17 echo "Installing libvips dependencies via apt-get" - apt-get install -y automake build-essential gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff5-dev libexif-dev libxml2-dev swig libmagickwand-dev curl + apt-get install -y automake build-essential gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff5-dev libexif-dev liblcms2-dev libxml2-dev swig libmagickwand-dev curl install_libvips_from_source ;; precise|wheezy|maya) @@ -102,7 +102,7 @@ case $(uname -s) in echo "Installing libvips dependencies via apt-get" add-apt-repository -y ppa:lyrasis/precise-backports apt-get update - apt-get install -y automake build-essential gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff4-dev libexif-dev libxml2-dev swig libmagickwand-dev curl + apt-get install -y automake build-essential gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff4-dev libexif-dev liblcms2-dev libxml2-dev swig libmagickwand-dev curl install_libvips_from_source ;; *) @@ -119,14 +119,14 @@ case $(uname -s) in # RHEL/CentOS 7 echo "Installing libvips dependencies via yum" yum groupinstall -y "Development Tools" - yum install -y gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel ImageMagick-devel gobject-introspection-devel libwebp-devel curl + yum install -y gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel lcms-devel ImageMagick-devel gobject-introspection-devel libwebp-devel curl install_libvips_from_source "--prefix=/usr" ;; "Red Hat Enterprise Linux release 6."*|"CentOS release 6."*|"Scientific Linux release 6."*) # RHEL/CentOS 6 echo "Installing libvips dependencies via yum" yum groupinstall -y "Development Tools" - yum install -y gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel ImageMagick-devel curl + yum install -y gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel lcms-devel ImageMagick-devel curl yum install -y http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm yum install -y --enablerepo=nux-dextop gobject-introspection-devel yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm diff --git a/src/resize.cc b/src/resize.cc index cbc470f3..b5de117f 100755 --- a/src/resize.cc +++ b/src/resize.cc @@ -31,7 +31,7 @@ struct ResizeBaton { std::string fileIn; void* bufferIn; size_t bufferInLength; - std::string iccProfileCmyk; + std::string iccProfilePath; std::string output; std::string outputFormat; void* bufferOut; @@ -271,21 +271,24 @@ class ResizeWorker : public NanAsyncWorker { // Ensure we're using a device-independent colour space if (HasProfile(image)) { - // Convert to CIELAB using embedded profile - VipsImage *profile; - if (vips_icc_import(image, &profile, "pcs", VIPS_PCS_XYZ, "embedded", TRUE, NULL)) { + // 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)) { return Error(baton, hook); } - vips_object_local(hook, profile); - image = profile; + vips_object_local(hook, transformed); + image = transformed; } else if (image->Type == VIPS_INTERPRETATION_CMYK) { - // Convert to CIELAB using default "USWebCoatedSWOP" CMYK profile - VipsImage *profile; - if (vips_icc_import(image, &profile, "pcs", VIPS_PCS_XYZ, "input_profile", (baton->iccProfileCmyk).c_str(), NULL)) { + // 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)) { return Error(baton, hook); } - vips_object_local(hook, profile); - image = profile; + vips_object_local(hook, transformed); + image = transformed; } // Flatten image to remove alpha channel @@ -831,7 +834,7 @@ NAN_METHOD(resize) { baton->bufferIn = node::Buffer::Data(buffer); } // ICC profile to use when input CMYK image has no embedded profile - baton->iccProfileCmyk = *String::Utf8Value(options->Get(NanNew("iccProfileCmyk"))->ToString()); + baton->iccProfilePath = *String::Utf8Value(options->Get(NanNew("iccProfilePath"))->ToString()); // Extract image options baton->topOffsetPre = options->Get(NanNew("topOffsetPre"))->Int32Value(); baton->leftOffsetPre = options->Get(NanNew("leftOffsetPre"))->Int32Value();