make jpeg pyr write work with tiff4

there was a problem with sizing tiles in chrominance subsample mode
This commit is contained in:
John Cupitt 2012-06-02 17:42:42 +01:00
parent d98f5a28fc
commit f65f9088f6
2 changed files with 22 additions and 4 deletions

View File

@ -2,6 +2,7 @@
- better resolution unit handling in deprecated im_vips2tiff()
- use TIFF_CFLAGS output from pkg-config (thanks Jay)
- much faster vips_argument_map()
- make jpeg pyramids work with tiff4
19/4/12 started 7.28.5
- ifthenelse blend mode was broken

View File

@ -126,6 +126,9 @@
* 2/12/11
* - make into a simple function call ready to be wrapped as a new-style
* VipsForeign class
* 2/6/12
* - copy jpeg pyramid in gather in RGB mode ... tiff4 doesn't do ycbcr
* mode
*/
/*
@ -904,7 +907,8 @@ shrink_region( VipsRegion *from, VipsRect *area,
/* Write a tile from a layer.
*/
static int
save_tile( TiffWrite *tw, TIFF *tif, VipsPel *tbuf, VipsRegion *reg, VipsRect *area )
save_tile( TiffWrite *tw,
TIFF *tif, VipsPel *tbuf, VipsRegion *reg, VipsRect *area )
{
/* Have to repack pixels.
*/
@ -1340,9 +1344,21 @@ tiff_copy( TiffWrite *tw, TIFF *out, TIFF *in )
/* TIFFTAG_JPEGQUALITY is a pesudo-tag, so we can't copy it.
* Set explicitly from TiffWrite.
*/
if( tw->compression == COMPRESSION_JPEG )
if( tw->compression == COMPRESSION_JPEG ) {
TIFFSetField( out, TIFFTAG_JPEGQUALITY, tw->jpqual );
/* Enable rgb->ycbcr conversion in the jpeg write. See also
* the photometric selection below.
*/
TIFFSetField( out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB );
/* And we want ycbcr expanded to rgb on read. Otherwise
* TIFFTileSize() will give us the size of a chrominance
* subsampled tile.
*/
TIFFSetField( in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB );
}
/* We can't copy profiles :( Set again from TiffWrite.
*/
if( embed_profile( tw, out ) )
@ -1357,7 +1373,7 @@ tiff_copy( TiffWrite *tw, TIFF *out, TIFF *in )
* here to save compression/decompression, but sadly it seems
* not to work :-( investigate at some point.
*/
len = TIFFReadEncodedTile( in, tile, buf, (tsize_t) -1 );
len = TIFFReadEncodedTile( in, tile, buf, -1 );
if( len < 0 ||
TIFFWriteEncodedTile( out, tile, buf, len ) < 0 ) {
vips_free( buf );
@ -1525,7 +1541,8 @@ vips__tiff_write( VipsImage *in, const char *filename,
/* Gather layers together into final pyramid file.
*/
if( tw->pyramid && gather_pyramid( tw ) ) {
if( tw->pyramid &&
gather_pyramid( tw ) ) {
free_tiff_write( tw );
return( -1 );
}