fix jpeg tiff pyramid save

we were not copying the quant tables on lower pyr levels correctly

add a test too
This commit is contained in:
John Cupitt 2021-06-28 20:24:00 +01:00
parent fc9e7ad2b3
commit 95bf1367ba
3 changed files with 17 additions and 5 deletions

View File

@ -5,6 +5,7 @@
- command-line programs set glib prgname (no longer set for you by VIPS_INIT)
- enable strip chopping for TIFF read [DavidStorm]
- disable modules by default for static builds [kleisauke]
- fix jpeg tiff pyramid save
14/8/20 started 8.11
- add vips_jpegload_source() and vips_svgload_source() to public C API

View File

@ -2029,12 +2029,17 @@ wtiff_copy_tiff( Wtiff *wtiff, TIFF *out, TIFF *in )
for( tile_no = 0; tile_no < n; tile_no++ ) {
tsize_t len;
len = TIFFReadRawTile( in, tile_no,
wtiff->compressed_buf, wtiff->compressed_buf_length );
if( len <= 0 ||
TIFFWriteRawTile( out, tile_no,
wtiff->compressed_buf, len ) < 0 )
/* TIFFReadRawTile()/TIFFWriteRawTile() would save us
* decompress/recompress, but they won't work for
* JPEG-compressed tiles since they won't copy the
* JPEG quant tables we need.
*/
len = TIFFReadEncodedTile( in, tile_no, buf, -1 );
if( len < 0 ||
TIFFWriteEncodedTile( out, tile_no, buf, len ) < 0 ) {
g_free( buf );
return( -1 );
}
}
g_free( buf );

View File

@ -415,6 +415,12 @@ class TestForeign:
im = pyvips.Image.new_from_file(TIF4_FILE)
self.save_load_file(".tif", "[bitdepth=4]", im)
filename = temp_filename(self.tempdir, '.tif')
self.colour.write_to_file(filename, pyramid=True, compression="jpeg")
x = pyvips.Image.new_from_file(filename, page=2)
assert x.width == 72
assert abs(x.avg() - 117.3) < 1
filename = temp_filename(self.tempdir, '.tif')
x = pyvips.Image.new_from_file(TIF_FILE)
x = x.copy()