From e9e23536eb94a50d47f34725939fa3c9b3234a90 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 5 Dec 2011 21:41:57 +0000 Subject: [PATCH] fix tiled tiff read --- TODO | 2 ++ libvips/conversion/tilecache.c | 6 +++--- libvips/foreign/foreign.c | 2 +- libvips/foreign/tiff2vips.c | 14 ++++++++++++-- libvips/foreign/tiffload.c | 3 +-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 8f0b238d..47fec3ad 100644 --- a/TODO +++ b/TODO @@ -20,6 +20,8 @@ - "header fred.png" does not work, since header uses im_open() which uses VipsForeign +- "header x.tif[page=7]" does not work + diff --git a/libvips/conversion/tilecache.c b/libvips/conversion/tilecache.c index a881481d..8aed10db 100644 --- a/libvips/conversion/tilecache.c +++ b/libvips/conversion/tilecache.c @@ -403,14 +403,14 @@ vips_tile_cache_class_init( VipsTileCacheClass *class ) VIPS_ARG_INT( class, "tile_width", 3, _( "Tile width" ), - _( "TIle width in pixels" ), + _( "Tile width in pixels" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsTileCache, tile_width ), 1, 1000000, 128 ); VIPS_ARG_INT( class, "tile_height", 3, _( "Tile height" ), - _( "TIle height in pixels" ), + _( "Tile height in pixels" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsTileCache, tile_height ), 1, 1000000, 128 ); @@ -470,7 +470,7 @@ vips_tilecache( VipsImage *in, VipsImage **out, ... ) int result; va_start( ap, out ); - result = vips_call_split( "cache", ap, in, out ); + result = vips_call_split( "tilecache", ap, in, out ); va_end( ap ); return( result ); diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index d5fa79bc..eb1f75e0 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -478,7 +478,7 @@ vips_foreign_load_start_cb( VipsImage *out, void *a, void *dummy ) */ if( load->disc && disc_threshold && - (load->flags & VIPS_FOREIGN_PARTIAL) && + !(load->flags & VIPS_FOREIGN_PARTIAL) && image_size > disc_threshold ) if( !(load->real = vips_image_new_disc_temp( "%s.v" )) ) return( NULL ); diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index 581e45a6..25f7a6d4 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -1253,6 +1253,10 @@ read_tilewise( ReadTiff *rtiff, VipsImage *out ) VipsImage *raw; VipsImage *t; +#ifdef DEBUG + printf( "tiff2vips: read_tilewise\n" ); +#endif /*DEBUG*/ + /* Get tiling geometry. */ if( !tfget32( rtiff->tiff, TIFFTAG_TILEWIDTH, &rtiff->twidth ) || @@ -1276,7 +1280,7 @@ read_tilewise( ReadTiff *rtiff, VipsImage *out ) /* Process and save as VIPS. */ - vips_demand_hint( out, + vips_demand_hint( raw, VIPS_DEMAND_STYLE_SMALLTILE, NULL ); if( vips_image_generate( raw, tiff_seq_start, tiff_fill_region, tiff_seq_stop, @@ -1292,9 +1296,10 @@ read_tilewise( ReadTiff *rtiff, VipsImage *out ) NULL ) ) return( -1 ); if( vips_image_write( t, out ) ) { - VIPS_UNREF( t ); + g_object_unref( t ); return( -1 ); } + g_object_unref( t ); return( 0 ); } @@ -1318,6 +1323,10 @@ read_stripwise( ReadTiff *rtiff, VipsImage *out ) int i; PEL *p; +#ifdef DEBUG + printf( "tiff2vips: read_stripwise\n" ); +#endif /*DEBUG*/ + if( parse_header( rtiff, out ) ) return( -1 ); @@ -1471,6 +1480,7 @@ vips__tiff_read( const char *filename, VipsImage *out, int page ) #ifdef DEBUG printf( "tiff2vips: libtiff version is \"%s\"\n", TIFFGetVersion() ); + printf( "tiff2vips: libtiff starting for %s\n", filename ); #endif /*DEBUG*/ TIFFSetErrorHandler( vips__thandler_error ); diff --git a/libvips/foreign/tiffload.c b/libvips/foreign/tiffload.c index 5bd7a45d..54be849d 100644 --- a/libvips/foreign/tiffload.c +++ b/libvips/foreign/tiffload.c @@ -31,7 +31,6 @@ */ /* -#define DEBUG_VERBOSE #define DEBUG */ @@ -90,7 +89,7 @@ vips_foreign_load_tiff_get_flags( VipsForeignLoad *load ) VipsForeignFlags flags; flags = 0; - if( vips__istifftiled( tiff->filename ) ) + if( vips__istifftiled( tiff->filename ) ) flags |= VIPS_FOREIGN_PARTIAL; return( flags );