From 25ad2b7a535dd16a085f00b7008b12dde80e20fb Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 12 Jul 2012 09:05:14 +0100 Subject: [PATCH] turn off seq mode in vips7 the new sequential mode readers for tiff/jpg/png were not working well from the vips7 command-line: they either decompressed twice, or handed over a sequential mode image it should now work as well as it did pre-seq. --- ChangeLog | 1 + TODO | 28 ++++++++++++++++++++++++ libvips/deprecated/im_jpeg2vips.c | 36 ++++++++++++++++++++++++++++--- libvips/deprecated/im_png2vips.c | 12 +++++++++++ libvips/deprecated/im_tiff2vips.c | 14 ++++++++++++ libvips/iofuncs/operation.c | 2 +- 6 files changed, 89 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e44fe7dc..3a0bafd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ - added VIPS_OPERATION_SEQUENTIAL flag - vips8 command-line interface uses this to turn sequential mode on automatically when possible +- better handling of input files in vips7 command-line interface 18/6/12 started 7.28.9 - slightly more memory debugging output diff --git a/TODO b/TODO index d1e46f21..37f1d3eb 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,31 @@ +- try: + +$ vips list classes | grep -i open +** DEBUG_FATAL + VipsFormatExr (exr), OpenEXR, (.exr) is_a load get_flags + VipsFormatOpenslide (im_openslide), Openslide, (.svs, .vms, .vmu, .ndpi, .mrxs, .tif) is_a load get_flags + VipsForeignLoadOpenexr (openexrload), load an OpenEXR image (.exr), priority=0, is_a, get_flags, get_flags_filename, header, load + + im_exr2vips (im_exr2vips), convert an OpenEXR file to VIPS, from package "format" + im_binfile (im_binfile), open a headerless binary file, from package "iofuncs" + + why the im_ in "VipsFormatOpenslide (im_openslide)"? + + we configured without openslide, why is it there at all? + + test with openslide available + + +- try + + vips im_extract_bands /tmp/input.tiff /tmp/out.tif 0 3 + + with a huhuhuhge image, hits 4gb and sits there, no error? + + + + + - test "rs" mode can't see the code for "rd" mode? diff --git a/libvips/deprecated/im_jpeg2vips.c b/libvips/deprecated/im_jpeg2vips.c index 64da7d57..82fe29d5 100644 --- a/libvips/deprecated/im_jpeg2vips.c +++ b/libvips/deprecated/im_jpeg2vips.c @@ -51,8 +51,8 @@ #include #include "../foreign/jpeg.h" -int -im_jpeg2vips( const char *name, IMAGE *out ) +static int +jpeg2vips( const char *name, IMAGE *out, gboolean header_only ) { char filename[FILENAME_MAX]; char mode[FILENAME_MAX]; @@ -97,12 +97,41 @@ im_jpeg2vips( const char *name, IMAGE *out ) * order to avoid the foreign.c mechanisms for load-via-disc and stuff * like that. */ - if( vips__jpeg_read_file( filename, out, FALSE, shrink, fail_on_warn ) ) + + /* We need to be compatible with the pre-sequential mode + * im_jpeg2vips(). This returned a "t" if given a "p" image, since it + * used writeline. + * + * If we're writing the image to a "p", switch it to a "t". + */ + + if( !header_only && + out->dtype == VIPS_IMAGE_PARTIAL ) { + if( vips__image_wio_output( out ) ) + return( -1 ); + } + + if( vips__jpeg_read_file( filename, out, + header_only, shrink, fail_on_warn ) ) return( -1 ); return( 0 ); } +int +im_jpeg2vips( const char *name, IMAGE *out ) +{ + return( jpeg2vips( name, out, FALSE ) ); +} + +/* By having a separate header func, we get lazy.c to open via disc/mem. + */ +static int +im_jpeg2vips_header( const char *name, IMAGE *out ) +{ + return( jpeg2vips( name, out, TRUE ) ); +} + int im_bufjpeg2vips( void *buf, size_t len, IMAGE *out, gboolean header_only ) { @@ -151,6 +180,7 @@ vips_format_jpeg_class_init( VipsFormatJpegClass *class ) object_class->description = _( "JPEG" ); format_class->is_a = isjpeg; + format_class->header = im_jpeg2vips_header; format_class->load = im_jpeg2vips; format_class->save = im_vips2jpeg; format_class->suffs = jpeg_suffs; diff --git a/libvips/deprecated/im_png2vips.c b/libvips/deprecated/im_png2vips.c index cb9e7eab..5d899c4e 100644 --- a/libvips/deprecated/im_png2vips.c +++ b/libvips/deprecated/im_png2vips.c @@ -61,6 +61,18 @@ im_png2vips( const char *name, IMAGE *out ) ; } + /* We need to be compatible with the pre-sequential mode + * im_png2vips(). This returned a "t" if given a "p" image, since it + * used writeline. + * + * If we're writing the image to a "p", switch it to a "t". + */ + + if( out->dtype == VIPS_IMAGE_PARTIAL ) { + if( vips__image_wio_output( out ) ) + return( -1 ); + } + if( vips__png_read( filename, out ) ) return( -1 ); diff --git a/libvips/deprecated/im_tiff2vips.c b/libvips/deprecated/im_tiff2vips.c index dd54c41c..1e0fb6ff 100644 --- a/libvips/deprecated/im_tiff2vips.c +++ b/libvips/deprecated/im_tiff2vips.c @@ -70,6 +70,20 @@ im_tiff2vips( const char *name, IMAGE *out ) ; } + /* We need to be compatible with the pre-sequential mode + * im_tiff2vips(). This returned a "t" if given a "p" image, since it + * used writeline. + * + * If we're writing the image to a "p", switch it to a "t". And only + * for non-tiled (strip) images which we write with writeline. + */ + + if( !vips__istifftiled( filename ) && + out->dtype == VIPS_IMAGE_PARTIAL ) { + if( vips__image_wio_output( out ) ) + return( -1 ); + } + if( vips__tiff_read( filename, out, page ) ) return( -1 ); diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index e74e8d33..f93cc4a9 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -243,7 +243,7 @@ vips_operation_summary( VipsObject *object, VipsBuf *buf ) VipsOperation *operation = VIPS_OPERATION( object ); VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS( object ); - vips_buf_appendf( buf, "%s", object_class->nickname ); + vips_buf_appendf( buf, "- %s", object_class->nickname ); vips_argument_map( VIPS_OBJECT( operation ), vips_operation_vips_operation_print_summary_arg, buf, NULL );