small tiff load improvements

This commit is contained in:
John Cupitt 2013-09-23 16:59:15 +01:00
parent a19a8ba9cb
commit cbe165f6c5

View File

@ -171,8 +171,8 @@
*/ */
/* /*
*/
#define DEBUG #define DEBUG
*/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
@ -660,7 +660,8 @@ parse_greyscale( ReadTiff *rtiff, VipsImage *out )
return( -1 ); return( -1 );
out->Bands = rtiff->samples_per_pixel; out->Bands = rtiff->samples_per_pixel;
out->BandFmt = guess_format( rtiff ); if( (out->BandFmt = guess_format( rtiff )) == VIPS_FORMAT_NOTSET )
return( -1 );
out->Coding = VIPS_CODING_NONE; out->Coding = VIPS_CODING_NONE;
if( rtiff->bits_per_sample == 16 ) if( rtiff->bits_per_sample == 16 )
@ -811,7 +812,8 @@ static int
parse_copy( ReadTiff *rtiff, VipsImage *out ) parse_copy( ReadTiff *rtiff, VipsImage *out )
{ {
out->Bands = rtiff->samples_per_pixel; out->Bands = rtiff->samples_per_pixel;
out->BandFmt = guess_format( rtiff ); if( (out->BandFmt = guess_format( rtiff )) == VIPS_FORMAT_NOTSET )
return( -1 );
out->Coding = VIPS_CODING_NONE; out->Coding = VIPS_CODING_NONE;
if( rtiff->samples_per_pixel >= 3 && if( rtiff->samples_per_pixel >= 3 &&
@ -965,6 +967,12 @@ parse_header( ReadTiff *rtiff, VipsImage *out )
uint16 v; uint16 v;
TIFFGetFieldDefaulted( rtiff->tiff, TIFFTAG_SAMPLEFORMAT, &v ); TIFFGetFieldDefaulted( rtiff->tiff, TIFFTAG_SAMPLEFORMAT, &v );
/* Some images have this set to void, bizarre.
*/
if( v == SAMPLEFORMAT_VOID )
v = SAMPLEFORMAT_UINT;
rtiff->sample_format = v; rtiff->sample_format = v;
} }
@ -1007,6 +1015,17 @@ parse_header( ReadTiff *rtiff, VipsImage *out )
if( pick_reader( rtiff )( rtiff, out ) ) if( pick_reader( rtiff )( rtiff, out ) )
return( -1 ); return( -1 );
/* Double check: in memcpy mode, the vips linesize should exactly
* match the tiff line size.
*/
if( rtiff->memcpy &&
TIFFScanlineSize( rtiff->tiff ) !=
VIPS_IMAGE_SIZEOF_LINE( out ) ) {
vips_error( "tiff2vips",
"%s", _( "unsupported tiff image type" ) );
return( -1 );
}
/* Read any ICC profile. /* Read any ICC profile.
*/ */
if( TIFFGetField( rtiff->tiff, if( TIFFGetField( rtiff->tiff,