fix interlaced thumbnails

we need to cache the thumbnail before we write it in case the writer
needs to make several passes

see https://github.com/jcupitt/libvips/issues/140
This commit is contained in:
John Cupitt 2014-06-30 12:07:00 +01:00
parent c2a8c542b6
commit 8c82ffb865
3 changed files with 22 additions and 6 deletions

View File

@ -1,3 +1,6 @@
30/6/14 started 7.40.3
- fix interlaced thumbnails in vipsthumbnail, thanks lovell
25/6/14 started 7.40.2
- dzsave write to zip stops at 4gb, thanks bgilbert
- improve short option name handling, thanks bgilbert

View File

@ -2,7 +2,7 @@
# also update the version number in the m4 macros below
AC_INIT([vips], [7.40.2], [vipsip@jiscmail.ac.uk])
AC_INIT([vips], [7.40.3], [vipsip@jiscmail.ac.uk])
# required for gobject-introspection
AC_PREREQ(2.62)
@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning
m4_define([vips_major_version], [7])
m4_define([vips_minor_version], [40])
m4_define([vips_micro_version], [2])
m4_define([vips_micro_version], [3])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])
@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date`
# binary interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=38
LIBRARY_REVISION=0
LIBRARY_REVISION=1
LIBRARY_AGE=0
# patched into include/vips/version.h

View File

@ -49,6 +49,8 @@
* 7/3/14
* - remove the embedded thumbnail reader, embedded thumbnails are too
* unlike the main image wrt. rotation / colour / etc.
* 30/6/14
* - fix interlaced thumbnail output, thanks lovell
*/
#ifdef HAVE_CONFIG_H
@ -585,8 +587,10 @@ thumbnail_rotate( VipsObject *process, VipsImage *im )
* (eg.) "/poop/tn_somefile.jpg".
*/
static int
thumbnail_write( VipsImage *im, const char *filename )
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];
@ -618,7 +622,16 @@ thumbnail_write( VipsImage *im, const char *filename )
g_free( file );
if( vips_image_write_to_file( im, output_name, NULL ) ) {
/* 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 ) ) {
g_free( output_name );
return( -1 );
}
@ -644,7 +657,7 @@ thumbnail_process( VipsObject *process, const char *filename )
thumbnail_shrink( process, in, interp, sharpen )) ||
!(crop = thumbnail_crop( process, thumbnail )) ||
!(rotate = thumbnail_rotate( process, crop )) ||
thumbnail_write( rotate, filename ) )
thumbnail_write( process, rotate, filename ) )
return( -1 );
return( 0 );