fix thumbnail of mono image

we were using RGB as the shrink space
This commit is contained in:
John Cupitt 2020-05-27 15:24:27 +01:00
parent 474bfe3782
commit aaebb3b346
2 changed files with 14 additions and 4 deletions

View File

@ -628,6 +628,11 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer )
int orientation; int orientation;
#ifdef DEBUG
printf( "wtiff_write_header: sub %d, width %d, height %d\n",
layer->sub, layer->width, layer->height );
#endif /*DEBUG*/
/* Output base header fields. /* Output base header fields.
*/ */
TIFFSetField( tif, TIFFTAG_IMAGEWIDTH, layer->width ); TIFFSetField( tif, TIFFTAG_IMAGEWIDTH, layer->width );
@ -1699,10 +1704,10 @@ write_strip( VipsRegion *region, VipsRect *area, void *a )
Wtiff *wtiff = (Wtiff *) a; Wtiff *wtiff = (Wtiff *) a;
Layer *layer = wtiff->layer; Layer *layer = wtiff->layer;
#ifdef DEBUG #ifdef DEBUG_VERBOSE
printf( "write_strip: strip at %d, height %d\n", printf( "write_strip: strip at %d, height %d\n",
area->top, area->height ); area->top, area->height );
#endif/*DEBUG*/ #endif/*DEBUG_VERBOSE*/
for(;;) { for(;;) {
VipsRect *to = &layer->strip->valid; VipsRect *to = &layer->strip->valid;

View File

@ -524,13 +524,12 @@ vips_thumbnail_build( VipsObject *object )
{ {
VipsThumbnail *thumbnail = VIPS_THUMBNAIL( object ); VipsThumbnail *thumbnail = VIPS_THUMBNAIL( object );
VipsImage **t = (VipsImage **) vips_object_local_array( object, 15 ); VipsImage **t = (VipsImage **) vips_object_local_array( object, 15 );
VipsInterpretation interpretation = thumbnail->linear ?
VIPS_INTERPRETATION_scRGB : VIPS_INTERPRETATION_sRGB;
VipsImage *in; VipsImage *in;
int preshrunk_page_height; int preshrunk_page_height;
double hshrink; double hshrink;
double vshrink; double vshrink;
VipsInterpretation interpretation;
/* TRUE if we've done the import of an ICC transform and still need to /* TRUE if we've done the import of an ICC transform and still need to
* export. * export.
@ -628,6 +627,12 @@ vips_thumbnail_build( VipsObject *object )
*/ */
if( in->Type == VIPS_INTERPRETATION_CMYK ) if( in->Type == VIPS_INTERPRETATION_CMYK )
have_imported = TRUE; have_imported = TRUE;
if( thumbnail->linear )
interpretation = VIPS_INTERPRETATION_scRGB;
else if( in->Bands < 3 )
interpretation = VIPS_INTERPRETATION_B_W;
else
interpretation = VIPS_INTERPRETATION_sRGB;
g_info( "converting to processing space %s", g_info( "converting to processing space %s",
vips_enum_nick( VIPS_TYPE_INTERPRETATION, interpretation ) ); vips_enum_nick( VIPS_TYPE_INTERPRETATION, interpretation ) );
if( vips_colourspace( in, &t[2], interpretation, NULL ) ) if( vips_colourspace( in, &t[2], interpretation, NULL ) )