diff --git a/ChangeLog b/ChangeLog index 3db8a72f..88717fe8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ - fix a possible segv with very wide images [f1ac] - revise premultiply, again [jjonesrs] - revise profile handling in vipsthumbnail +- fix tiff deflate predictor setting [Adios] 18/12/20 started 8.10.5 - fix potential /0 in animated webp load [lovell] diff --git a/libvips/foreign/tiffsave.c b/libvips/foreign/tiffsave.c index c0565c59..57eda43b 100644 --- a/libvips/foreign/tiffsave.c +++ b/libvips/foreign/tiffsave.c @@ -590,8 +590,8 @@ vips_foreign_save_tiff_buffer_init( VipsForeignSaveTiffBuffer *buffer ) * User @level to set the ZSTD compression level. Use @lossless to * set WEBP lossless mode on. Use @Q to set the WEBP compression level. * - * Use @predictor to set the predictor for lzw and deflate compression. It - * defaults to #VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL, meaning horizontal + * Use @predictor to set the predictor for lzw, deflate and zstd compression. + * It defaults to #VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL, meaning horizontal * differencing. Please refer to the libtiff * specifications for further discussion of various predictors. * diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index 1ea73895..6c8d6d71 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -333,9 +333,9 @@ struct _Wtiff { VipsPel *tbuf; /* TIFF output buffer */ int tls; /* Tile line size */ - int compression; /* Compression type */ + int compression; /* libtiff compression type */ int Q; /* JPEG q-factor, webp level */ - int predictor; /* Predictor value */ + int predictor; /* libtiff predictor type */ int tile; /* Tile or not */ int tilew, tileh; /* Tile size */ int pyramid; /* Wtiff pyramid */ @@ -663,8 +663,9 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer ) TIFFSetField( tif, TIFFTAG_ZSTD_LEVEL, wtiff->level ); #endif /*HAVE_TIFF_COMPRESSION_WEBP*/ - if( (wtiff->compression == VIPS_FOREIGN_TIFF_COMPRESSION_DEFLATE || - wtiff->compression == VIPS_FOREIGN_TIFF_COMPRESSION_LZW) && + if( (wtiff->compression == COMPRESSION_ADOBE_DEFLATE || + wtiff->compression == COMPRESSION_ZSTD || + wtiff->compression == COMPRESSION_LZW) && wtiff->predictor != VIPS_FOREIGN_TIFF_PREDICTOR_NONE ) TIFFSetField( tif, TIFFTAG_PREDICTOR, wtiff->predictor ); @@ -1866,6 +1867,12 @@ wtiff_copy_tiff( Wtiff *wtiff, TIFF *out, TIFF *in ) TIFFSetField( out, TIFFTAG_ZSTD_LEVEL, wtiff->level ); #endif /*HAVE_TIFF_COMPRESSION_WEBP*/ + if( (wtiff->compression == COMPRESSION_ADOBE_DEFLATE || + wtiff->compression == COMPRESSION_ZSTD || + wtiff->compression == COMPRESSION_LZW) && + wtiff->predictor != VIPS_FOREIGN_TIFF_PREDICTOR_NONE ) + TIFFSetField( out, TIFFTAG_PREDICTOR, wtiff->predictor ); + /* We can't copy profiles or xmp :( Set again from wtiff. */ if( !wtiff->strip )