add tiff zstd predictor support

This commit is contained in:
AdiosF6F 2021-03-04 22:38:47 +08:00
parent 86a6fd9d18
commit 4d0252f31c
No known key found for this signature in database
GPG Key ID: B9E162035C9485F3
2 changed files with 14 additions and 4 deletions

View File

@ -590,8 +590,8 @@ vips_foreign_save_tiff_buffer_init( VipsForeignSaveTiffBuffer *buffer )
* User @level to set the ZSTD compression level. Use @lossless to * User @level to set the ZSTD compression level. Use @lossless to
* set WEBP lossless mode on. Use @Q to set the WEBP compression level. * 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 * Use @predictor to set the predictor for lzw, deflate and zstd compression.
* defaults to #VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL, meaning horizontal * It defaults to #VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL, meaning horizontal
* differencing. Please refer to the libtiff * differencing. Please refer to the libtiff
* specifications for further discussion of various predictors. * specifications for further discussion of various predictors.
* *

View File

@ -659,8 +659,13 @@ wtiff_write_header( Wtiff *wtiff, Layer *layer )
TIFFSetField( tif, TIFFTAG_WEBP_LEVEL, wtiff->Q ); TIFFSetField( tif, TIFFTAG_WEBP_LEVEL, wtiff->Q );
TIFFSetField( tif, TIFFTAG_WEBP_LOSSLESS, wtiff->lossless ); TIFFSetField( tif, TIFFTAG_WEBP_LOSSLESS, wtiff->lossless );
} }
if( wtiff->compression == COMPRESSION_ZSTD ) if( wtiff->compression == COMPRESSION_ZSTD ) {
TIFFSetField( tif, TIFFTAG_ZSTD_LEVEL, wtiff->level ); 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*/ #endif /*HAVE_TIFF_COMPRESSION_WEBP*/
if( (wtiff->compression == COMPRESSION_ADOBE_DEFLATE || 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_LEVEL, wtiff->Q );
TIFFSetField( out, TIFFTAG_WEBP_LOSSLESS, wtiff->lossless ); TIFFSetField( out, TIFFTAG_WEBP_LOSSLESS, wtiff->lossless );
} }
if( wtiff->compression == COMPRESSION_ZSTD ) if( wtiff->compression == COMPRESSION_ZSTD ) {
TIFFSetField( out, TIFFTAG_ZSTD_LEVEL, wtiff->level ); 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*/ #endif /*HAVE_TIFF_COMPRESSION_WEBP*/
if( (wtiff->compression == COMPRESSION_ADOBE_DEFLATE || if( (wtiff->compression == COMPRESSION_ADOBE_DEFLATE ||