pngsave interlaced makes a copy of the image

interlaced png is hard to write: you have to make seven passes over the
image to make the whole file. It advertises itself as sequential, it
needs to only ake a single pass. Therefore, it must take a copy in
memory of the image to write.
This commit is contained in:
John Cupitt 2014-08-03 09:34:46 +01:00
parent d438649fcb
commit 004c98f296
4 changed files with 14 additions and 7 deletions

View File

@ -4,6 +4,7 @@
- don't exit() on memleak detected, just warn
- add "autocrop" option to openslide load
- argh fix affine, again
- pngsave in interlaced mode make a copy of the whole image
4/7/14 started 7.40.4
- fix vips_rawsave_fd(), thanks aferrero2707

3
TODO
View File

@ -2,9 +2,6 @@
change caching:
- png and jpg interlaced write need to make a memory copy before writing,
they advertse as seq, they need to be seq
- autorotate should make a mem copy if it find rotation is necessary
- remove second vips_cache()

View File

@ -58,6 +58,7 @@
* - attach IPCT data (app13), thanks Gary
* 2/10/13 Lovell Fuller
* - add optimize_coding parameter
* - add progressive mode
* 12/11/13
* - add "strip" option to remove all metadata
* 13/11/13

View File

@ -777,10 +777,18 @@ write_vips( Write *write, int compress, int interlace )
if( setjmp( png_jmpbuf( write->pPng ) ) )
return( -1 );
/* Check input image.
/* Check input image. If we are writing interlaced, we need to make 7
* passes over the image. We advertise ourselves as seq, so to ensure
* we only suck once from upstream, switch to WIO.
*/
if( vips_image_pio_input( in ) )
return( -1 );
if( interlace ) {
if( vips_image_wio_input( in ) )
return( -1 );
}
else {
if( vips_image_pio_input( in ) )
return( -1 );
}
if( compress < 0 || compress > 9 ) {
vips_error( "vips2png",
"%s", _( "compress should be in [0,9]" ) );
@ -813,7 +821,7 @@ write_vips( Write *write, int compress, int interlace )
in->Xsize, in->Ysize, bit_depth, color_type, interlace_type,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT );
/* Set resolution. libpnbg uses pixels per meter.
/* Set resolution. libpng uses pixels per meter.
*/
png_set_pHYs( write->pPng, write->pInfo,
VIPS_RINT( in->Xres * 1000 ), VIPS_RINT( in->Yres * 1000 ),