Skip to content

Commit

Permalink
improve the interpretation sanity checker
Browse files Browse the repository at this point in the history
it was rejecting int LABS
  • Loading branch information
jcupitt committed May 22, 2022
1 parent fd495bc commit 111f1d1
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions libvips/iofuncs/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,16 @@ vips_image_guess_interpretation( const VipsImage *image )
case VIPS_INTERPRETATION_LCH:
case VIPS_INTERPRETATION_sRGB:
case VIPS_INTERPRETATION_HSV:
if( image->Bands < 3 )
sane = FALSE;
break;

case VIPS_INTERPRETATION_scRGB:
case VIPS_INTERPRETATION_YXY:
if( image->Bands < 3 )
/* Need float values in 0 - 1.
*/
if( !vips_band_format_isfloat( image->BandFmt ) ||
image->Bands < 3 )
sane = FALSE;
break;

Expand All @@ -743,20 +750,22 @@ vips_image_guess_interpretation( const VipsImage *image )
break;

case VIPS_INTERPRETATION_LABS:
if( image->BandFmt != VIPS_FORMAT_SHORT )
/* Needs to be able to express +/- 32767
*/
if( vips_band_format_isuint( image->BandFmt ) ||
vips_band_format_is8bit( image->BandFmt ) ||
image->Bands < 3 )
sane = FALSE;
break;

case VIPS_INTERPRETATION_RGB16:
if( image->BandFmt == VIPS_FORMAT_CHAR ||
image->BandFmt == VIPS_FORMAT_UCHAR ||
if( vips_band_format_is8bit( image->BandFmt ) ||
image->Bands < 3 )
sane = FALSE;
break;

case VIPS_INTERPRETATION_GREY16:
if( image->BandFmt == VIPS_FORMAT_CHAR ||
image->BandFmt == VIPS_FORMAT_UCHAR )
if( vips_band_format_is8bit( image->BandFmt ) )
sane = FALSE;
break;

Expand Down

0 comments on commit 111f1d1

Please sign in to comment.