diff --git a/TODO b/TODO index c0688602..d9f4a5f3 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,13 @@ -- vipsthumbnail -t plus large -s seems to fail? +- try: - change caching: + $ vipsthumbnail Chicago.png --vips-concurrency=1 + memory: high-water mark 180.57 MB + $ vipsthumbnail Chicago.png --vips-concurrency=4 + memory: high-water mark 180.57 MB - - autorotate should make a mem copy if it find rotation is necessary + shouldn't memuse drop with concurrency 1? - - remove second vips_cache() +- bicubic adds noise to 255/255/255, why? try babe.jpg background - experiment with size down to two sizes above in vipsthumbnail @@ -18,7 +21,6 @@ -- bicubic adds noise to 255/255/255, why? try babe.jpg background diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index d40faa86..c3a36f56 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -862,7 +862,7 @@ write_vips( Write *write, int compress, int interlace ) /* Write data. */ for( i = 0; i < nb_passes; i++ ) - if( vips_sink_disc( write->in, write_png_block, write ) ) + if( vips_sink_disc( in, write_png_block, write ) ) return( -1 ); /* The setjmp() was held by our background writer: reset it. diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 10972f26..a8b7e6ab 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -2781,6 +2781,24 @@ vips_image_wio_input( VipsImage *image ) */ g_object_unref( t1 ); + /* We need to zap any start/gen/stop callbacks. If we don't, + * calling vips_region_prepare_to() later to read from this + * image will fail, since it will think it need to create the + * image, not read from it. + */ + image->start_fn = NULL; + image->generate_fn = NULL; + image->stop_fn = NULL; + image->client1 = NULL; + image->client2 = NULL; + + /* ... and that may confuse any regions which are trying to + * generate from this image. + */ + if( image->regions ) + vips_warn( "vips_image_wio_input", "%s", + "rewinding image with active regions" ); + break; case VIPS_IMAGE_OPENIN: diff --git a/tools/vipsthumbnail.c b/tools/vipsthumbnail.c index ab411e7d..c9925265 100644 --- a/tools/vipsthumbnail.c +++ b/tools/vipsthumbnail.c @@ -570,12 +570,18 @@ thumbnail_crop( VipsObject *process, VipsImage *im ) static VipsImage * thumbnail_rotate( VipsObject *process, VipsImage *im ) { - VipsImage **t = (VipsImage **) vips_object_local_array( process, 1 ); + VipsImage **t = (VipsImage **) vips_object_local_array( process, 2 ); + VipsAngle angle = get_angle( im ); - if( rotate_image ) { - if( vips_rot( im, &t[0], get_angle( im ), NULL ) ) + if( rotate_image && + angle != VIPS_ANGLE_0 ) { + /* Need to copy to memory, we have to stay seq. + */ + t[0] = vips_image_new_memory(); + if( vips_image_write( im, t[0] ) || + vips_rot( t[0], &t[1], angle, NULL ) ) return( NULL ); - im = t[0]; + im = t[1]; (void) vips_image_remove( im, ORIENTATION ); } @@ -589,8 +595,6 @@ thumbnail_rotate( VipsObject *process, VipsImage *im ) static int thumbnail_write( VipsObject *process, VipsImage *im, const char *filename ) { - VipsImage **t = (VipsImage **) vips_object_local_array( process, 1 ); - char *file; char *p; char buf[FILENAME_MAX]; @@ -622,16 +626,7 @@ thumbnail_write( VipsObject *process, VipsImage *im, const char *filename ) g_free( file ); - /* We need to cache the whole of the thumbnail before we write it - * in case we are writing an interlaced image. Interlaced png (for - * example) will make 7 passes over the image during write. - */ - if( vips_tilecache( im, &t[0], - "threaded", TRUE, - "persistent", TRUE, - "max_tiles", -1, - NULL ) || - vips_image_write_to_file( t[0], output_name, NULL ) ) { + if( vips_image_write_to_file( im, output_name, NULL ) ) { g_free( output_name ); return( -1 ); }