block use of RGB profiles with CMYK images

Detect and block a common error.

See https://github.com/libvips/libvips/issues/3139
This commit is contained in:
John Cupitt 2022-11-03 14:18:38 +00:00
parent 17ca29adc9
commit 3d29daf553
1 changed files with 18 additions and 8 deletions

View File

@ -478,16 +478,16 @@ static void
vips_icc_print_profile( const char *name, cmsHPROFILE profile )
{
static const cmsInfoType info_types[] = {
cmsInfoDescription,
cmsInfoManufacturer,
cmsInfoModel,
cmsInfoCopyright
cmsInfoDescription,
cmsInfoManufacturer,
cmsInfoModel,
cmsInfoCopyright
};
static const char *info_names[] = {
"description",
"manufacturer",
"model",
"copyright"
"description",
"manufacturer",
"model",
"copyright"
};
int i;
@ -589,6 +589,16 @@ vips_icc_load_profile_blob( VipsBlob *blob,
return( NULL );
}
/* Spot the common error of an RGB profile and a CMYK image.
*/
if( image &&
image->Type == VIPS_INTERPRETATION_CMYK &&
info->bands == 3 ) {
VIPS_FREEF( cmsCloseProfile, profile );
g_warning( "%s", _( "profile incompatible with image" ) );
return( NULL );
}
if( !cmsIsIntentSupported( profile, intent, direction ) ) {
VIPS_FREEF( cmsCloseProfile, profile );
g_warning( _( "profile does not support %s %s intent" ),