improve the interpretation sanity checker

it was rejecting int LABS
This commit is contained in:
John Cupitt 2022-05-22 14:05:01 +01:00
parent fd495bcd0a
commit 111f1d11df

View File

@ -726,9 +726,16 @@ vips_image_guess_interpretation( const VipsImage *image )
case VIPS_INTERPRETATION_LCH: case VIPS_INTERPRETATION_LCH:
case VIPS_INTERPRETATION_sRGB: case VIPS_INTERPRETATION_sRGB:
case VIPS_INTERPRETATION_HSV: case VIPS_INTERPRETATION_HSV:
if( image->Bands < 3 )
sane = FALSE;
break;
case VIPS_INTERPRETATION_scRGB: case VIPS_INTERPRETATION_scRGB:
case VIPS_INTERPRETATION_YXY: 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; sane = FALSE;
break; break;
@ -743,20 +750,22 @@ vips_image_guess_interpretation( const VipsImage *image )
break; break;
case VIPS_INTERPRETATION_LABS: 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; sane = FALSE;
break; break;
case VIPS_INTERPRETATION_RGB16: case VIPS_INTERPRETATION_RGB16:
if( image->BandFmt == VIPS_FORMAT_CHAR || if( vips_band_format_is8bit( image->BandFmt ) ||
image->BandFmt == VIPS_FORMAT_UCHAR ||
image->Bands < 3 ) image->Bands < 3 )
sane = FALSE; sane = FALSE;
break; break;
case VIPS_INTERPRETATION_GREY16: case VIPS_INTERPRETATION_GREY16:
if( image->BandFmt == VIPS_FORMAT_CHAR || if( vips_band_format_is8bit( image->BandFmt ) )
image->BandFmt == VIPS_FORMAT_UCHAR )
sane = FALSE; sane = FALSE;
break; break;