fix tiled tiff read

This commit is contained in:
John Cupitt 2011-12-05 21:41:57 +00:00
parent 0b8c31f85e
commit e9e23536eb
5 changed files with 19 additions and 8 deletions

2
TODO
View File

@ -20,6 +20,8 @@
- "header fred.png" does not work, since header uses im_open() which uses - "header fred.png" does not work, since header uses im_open() which uses
VipsForeign VipsForeign
- "header x.tif[page=7]" does not work

View File

@ -403,14 +403,14 @@ vips_tile_cache_class_init( VipsTileCacheClass *class )
VIPS_ARG_INT( class, "tile_width", 3, VIPS_ARG_INT( class, "tile_width", 3,
_( "Tile width" ), _( "Tile width" ),
_( "TIle width in pixels" ), _( "Tile width in pixels" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsTileCache, tile_width ), G_STRUCT_OFFSET( VipsTileCache, tile_width ),
1, 1000000, 128 ); 1, 1000000, 128 );
VIPS_ARG_INT( class, "tile_height", 3, VIPS_ARG_INT( class, "tile_height", 3,
_( "Tile height" ), _( "Tile height" ),
_( "TIle height in pixels" ), _( "Tile height in pixels" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsTileCache, tile_height ), G_STRUCT_OFFSET( VipsTileCache, tile_height ),
1, 1000000, 128 ); 1, 1000000, 128 );
@ -470,7 +470,7 @@ vips_tilecache( VipsImage *in, VipsImage **out, ... )
int result; int result;
va_start( ap, out ); va_start( ap, out );
result = vips_call_split( "cache", ap, in, out ); result = vips_call_split( "tilecache", ap, in, out );
va_end( ap ); va_end( ap );
return( result ); return( result );

View File

@ -478,7 +478,7 @@ vips_foreign_load_start_cb( VipsImage *out, void *a, void *dummy )
*/ */
if( load->disc && if( load->disc &&
disc_threshold && disc_threshold &&
(load->flags & VIPS_FOREIGN_PARTIAL) && !(load->flags & VIPS_FOREIGN_PARTIAL) &&
image_size > disc_threshold ) image_size > disc_threshold )
if( !(load->real = vips_image_new_disc_temp( "%s.v" )) ) if( !(load->real = vips_image_new_disc_temp( "%s.v" )) )
return( NULL ); return( NULL );

View File

@ -1253,6 +1253,10 @@ read_tilewise( ReadTiff *rtiff, VipsImage *out )
VipsImage *raw; VipsImage *raw;
VipsImage *t; VipsImage *t;
#ifdef DEBUG
printf( "tiff2vips: read_tilewise\n" );
#endif /*DEBUG*/
/* Get tiling geometry. /* Get tiling geometry.
*/ */
if( !tfget32( rtiff->tiff, TIFFTAG_TILEWIDTH, &rtiff->twidth ) || if( !tfget32( rtiff->tiff, TIFFTAG_TILEWIDTH, &rtiff->twidth ) ||
@ -1276,7 +1280,7 @@ read_tilewise( ReadTiff *rtiff, VipsImage *out )
/* Process and save as VIPS. /* Process and save as VIPS.
*/ */
vips_demand_hint( out, vips_demand_hint( raw,
VIPS_DEMAND_STYLE_SMALLTILE, NULL ); VIPS_DEMAND_STYLE_SMALLTILE, NULL );
if( vips_image_generate( raw, if( vips_image_generate( raw,
tiff_seq_start, tiff_fill_region, tiff_seq_stop, tiff_seq_start, tiff_fill_region, tiff_seq_stop,
@ -1292,9 +1296,10 @@ read_tilewise( ReadTiff *rtiff, VipsImage *out )
NULL ) ) NULL ) )
return( -1 ); return( -1 );
if( vips_image_write( t, out ) ) { if( vips_image_write( t, out ) ) {
VIPS_UNREF( t ); g_object_unref( t );
return( -1 ); return( -1 );
} }
g_object_unref( t );
return( 0 ); return( 0 );
} }
@ -1318,6 +1323,10 @@ read_stripwise( ReadTiff *rtiff, VipsImage *out )
int i; int i;
PEL *p; PEL *p;
#ifdef DEBUG
printf( "tiff2vips: read_stripwise\n" );
#endif /*DEBUG*/
if( parse_header( rtiff, out ) ) if( parse_header( rtiff, out ) )
return( -1 ); return( -1 );
@ -1471,6 +1480,7 @@ vips__tiff_read( const char *filename, VipsImage *out, int page )
#ifdef DEBUG #ifdef DEBUG
printf( "tiff2vips: libtiff version is \"%s\"\n", TIFFGetVersion() ); printf( "tiff2vips: libtiff version is \"%s\"\n", TIFFGetVersion() );
printf( "tiff2vips: libtiff starting for %s\n", filename );
#endif /*DEBUG*/ #endif /*DEBUG*/
TIFFSetErrorHandler( vips__thandler_error ); TIFFSetErrorHandler( vips__thandler_error );

View File

@ -31,7 +31,6 @@
*/ */
/* /*
#define DEBUG_VERBOSE
#define DEBUG #define DEBUG
*/ */
@ -90,7 +89,7 @@ vips_foreign_load_tiff_get_flags( VipsForeignLoad *load )
VipsForeignFlags flags; VipsForeignFlags flags;
flags = 0; flags = 0;
if( vips__istifftiled( tiff->filename ) ) if( vips__istifftiled( tiff->filename ) )
flags |= VIPS_FOREIGN_PARTIAL; flags |= VIPS_FOREIGN_PARTIAL;
return( flags ); return( flags );