use Type/Interpretation for using the format when saving

This commit is contained in:
Angel Sánchez 2019-11-19 11:26:34 +01:00
parent fa0514a4d4
commit dd79cfd89d

View File

@ -654,18 +654,15 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer )
TIFFSetField( tif, TIFFTAG_BITSPERSAMPLE, TIFFSetField( tif, TIFFTAG_BITSPERSAMPLE,
vips_format_sizeof( wtiff->im->BandFmt ) << 3 ); vips_format_sizeof( wtiff->im->BandFmt ) << 3 );
if( wtiff->im->Bands < 3 ) { if (wtiff->im->Type == VIPS_INTERPRETATION_B_W ||
/* Mono or mono + alpha. wtiff->im->Type == VIPS_INTERPRETATION_GREY16) {
*/ // Mono or mono + alpha.
photometric = wtiff->miniswhite ? photometric = wtiff->miniswhite ?
PHOTOMETRIC_MINISWHITE : PHOTOMETRIC_MINISWHITE :
PHOTOMETRIC_MINISBLACK; PHOTOMETRIC_MINISBLACK;
colour_bands = 1; colour_bands = 1;
} }
else { else if( wtiff->im->Type == VIPS_INTERPRETATION_LAB ||
/* Could be: RGB, CMYK, LAB, perhaps with extra alpha.
*/
if( wtiff->im->Type == VIPS_INTERPRETATION_LAB ||
wtiff->im->Type == VIPS_INTERPRETATION_LABS ) { wtiff->im->Type == VIPS_INTERPRETATION_LABS ) {
photometric = PHOTOMETRIC_CIELAB; photometric = PHOTOMETRIC_CIELAB;
colour_bands = 3; colour_bands = 3;
@ -704,7 +701,6 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer )
photometric = PHOTOMETRIC_RGB; photometric = PHOTOMETRIC_RGB;
colour_bands = 3; colour_bands = 3;
} }
}
alpha_bands = VIPS_CLIP( 0, alpha_bands = VIPS_CLIP( 0,
wtiff->im->Bands - colour_bands, MAX_ALPHA ); wtiff->im->Bands - colour_bands, MAX_ALPHA );