diff --git a/configure.ac b/configure.ac index 2cbd2f53..2b928842 100644 --- a/configure.ac +++ b/configure.ac @@ -1084,7 +1084,7 @@ if test x"$with_tiff" != x"no"; then ) fi -# WEBP in TIFF added in libtiff 4.0.10 +# ZSTD and WEBP in TIFF added in libtiff 4.0.10 if test x"$with_tiff" != x"no"; then save_INCLUDES="$INCLUDES" INCLUDES="$INCLUDES $TIFF_INCLUDES" diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index 6c8d6d71..626b36ba 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -659,12 +659,15 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer ) TIFFSetField( tif, TIFFTAG_WEBP_LEVEL, wtiff->Q ); TIFFSetField( tif, TIFFTAG_WEBP_LOSSLESS, wtiff->lossless ); } - if( wtiff->compression == COMPRESSION_ZSTD ) + if( wtiff->compression == COMPRESSION_ZSTD ) { TIFFSetField( tif, TIFFTAG_ZSTD_LEVEL, wtiff->level ); + if( wtiff->predictor != VIPS_FOREIGN_TIFF_PREDICTOR_NONE ) + TIFFSetField( tif, + TIFFTAG_PREDICTOR, wtiff->predictor ); + } #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( tif, TIFFTAG_PREDICTOR, wtiff->predictor ); @@ -1863,12 +1866,15 @@ wtiff_copy_tiff( Wtiff *wtiff, TIFF *out, TIFF *in ) TIFFSetField( out, TIFFTAG_WEBP_LEVEL, wtiff->Q ); TIFFSetField( out, TIFFTAG_WEBP_LOSSLESS, wtiff->lossless ); } - if( wtiff->compression == COMPRESSION_ZSTD ) + if( wtiff->compression == COMPRESSION_ZSTD ) { TIFFSetField( out, TIFFTAG_ZSTD_LEVEL, wtiff->level ); + if( wtiff->predictor != VIPS_FOREIGN_TIFF_PREDICTOR_NONE ) + TIFFSetField( out, + TIFFTAG_PREDICTOR, wtiff->predictor ); + } #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 );