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 29f3f130..05103a4e 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -659,8 +659,13 @@ 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 || @@ -1862,8 +1867,13 @@ 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 ||