transform cmyk->rgb automatically

if:

- we are writing a cmyk image
- there is an embedded profile
- the saver does not support cmyk

see https://github.com/jcupitt/libvips/issues/676
This commit is contained in:
John Cupitt 2017-06-12 18:19:20 +01:00
parent 7bcf0bb93f
commit 4d846534b8
4 changed files with 41 additions and 3 deletions

View File

@ -1,3 +1,7 @@
12/6/17 started 8.5.7
- transform cmyk->rgb automatically on write if there's an embedded profile
and the saver does not support cmyk
19/5/17 started 8.5.6
- tiff read with start page > 0 could break edge tiles or strips
- raise b64 limit to allow for huge profiles (thanks jaume)

View File

@ -2,7 +2,7 @@
# also update the version number in the m4 macros below
AC_INIT([vips], [8.5.6], [vipsip@jiscmail.ac.uk])
AC_INIT([vips], [8.5.7], [vipsip@jiscmail.ac.uk])
# required for gobject-introspection
AC_PREREQ(2.62)
@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning
m4_define([vips_major_version], [8])
m4_define([vips_minor_version], [5])
m4_define([vips_micro_version], [6])
m4_define([vips_micro_version], [7])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])
@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date`
# binary interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=49
LIBRARY_REVISION=5
LIBRARY_REVISION=6
LIBRARY_AGE=7
# patched into include/vips/version.h

View File

@ -596,6 +596,7 @@ static int
vips_icc_import_build( VipsObject *object )
{
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
VipsColour *colour = (VipsColour *) object;
VipsColourCode *code = (VipsColourCode *) object;
VipsIcc *icc = (VipsIcc *) object;
VipsIccImport *import = (VipsIccImport *) object;

View File

@ -14,6 +14,8 @@
* - forward progress signals from load
* 23/5/16
* - remove max-alpha stuff, this is now automatic
* 12/6/17
* - transform cmyk->rgb if there's an embedded profile
*/
/*
@ -1190,6 +1192,37 @@ vips__foreign_convert_saveable( VipsImage *in, VipsImage **ready,
}
}
/* If this image is CMYK and the saver is RGB-only, use lcms to try to
* import to XYZ. This will only work if the image has an embedded
* profile.
*/
if( in->Type == VIPS_INTERPRETATION_CMYK &&
in->Bands >= 4 &&
(saveable == VIPS_SAVEABLE_RGB ||
saveable == VIPS_SAVEABLE_RGBA ||
saveable == VIPS_SAVEABLE_RGBA_ONLY) ) {
VipsImage *out;
if( vips_icc_import( in, &out,
"pcs", VIPS_PCS_XYZ,
NULL ) ) {
g_object_unref( in );
return( -1 );
}
g_object_unref( in );
in = out;
/* We've imported to PCS, we must remove the embedded profile,
* since it no longer matches the image.
*
* For example, when converting CMYK JPG to RGB PNG, we need
* to remove the CMYK profile on import, or the png writer will
* try to attach it when we write the image as RGB.
*/
vips_image_remove( in, VIPS_META_ICC_NAME );
}
/* If this is something other than CMYK or RAD, eg. maybe a LAB image,
* we need to transform to RGB.
*/