From b14bac53a33b1461978df0f5deb4a46c727ddc79 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 5 Mar 2021 12:16:38 +0000 Subject: [PATCH] guard refs to ZSTD so we work on older libtiffs --- configure.ac | 2 +- libvips/foreign/vips2tiff.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) 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 );