Skip to content

Commit

Permalink
block use of RGB profiles with CMYK images
Browse files Browse the repository at this point in the history
Detect and block a common error.

See #3139
  • Loading branch information
jcupitt committed Nov 3, 2022
1 parent 17ca29a commit 3d29daf
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions libvips/colour/icc_transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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" ),
Expand Down

0 comments on commit 3d29daf

Please sign in to comment.