diff options
author | Norman Barker <norman.barker@mapbox.com> | 2018-11-20 11:54:01 -0600 |
---|---|---|
committer | Norman Barker <norman.barker@mapbox.com> | 2018-11-20 11:54:01 -0600 |
commit | c7774df9a7fe9c2f8d1268e48a34a5a2d5869387 (patch) | |
tree | 32fd01e0a9ea8d1ee8c801e7ea91dd76e2ce8e4d | |
parent | 6b7fc9f116a86d97ee8bc126b102faa8189f2b71 (diff) | |
download | libtiff-git-c7774df9a7fe9c2f8d1268e48a34a5a2d5869387.tar.gz |
fixed lossless webp compression config
-rw-r--r-- | libtiff/tif_webp.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/libtiff/tif_webp.c b/libtiff/tif_webp.c index a002f481..ee0a0649 100644 --- a/libtiff/tif_webp.c +++ b/libtiff/tif_webp.c @@ -349,6 +349,12 @@ TWebPSetupEncode(TIFF* tif) sp->state |= LSTATE_INIT_ENCODE; + if (!WebPPictureInit(&sp->sPicture)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error initializing WebP picture."); + return 0; + } + if (!WebPConfigInitInternal(&sp->sEncoderConfig, WEBP_PRESET_DEFAULT, sp->quality_level, WEBP_ENCODER_ABI_VERSION)) { @@ -357,9 +363,13 @@ TWebPSetupEncode(TIFF* tif) return 0; } -#if WEBP_ENCODER_ABI_VERSION >= 0x0100 - sp->sEncoderConfig.lossless = sp->lossless; -#endif + // WebPConfigInitInternal above sets lossless to false + #if WEBP_ENCODER_ABI_VERSION >= 0x0100 + sp->sEncoderConfig.lossless = sp->lossless; + if (sp->lossless) { + sp->sPicture.use_argb = 1; + } + #endif if (!WebPValidateConfig(&sp->sEncoderConfig)) { TIFFErrorExt(tif->tif_clientdata, module, @@ -367,12 +377,6 @@ TWebPSetupEncode(TIFF* tif) return 0; } - if (!WebPPictureInit(&sp->sPicture)) { - TIFFErrorExt(tif->tif_clientdata, module, - "Error initializing WebP picture."); - return 0; - } - return 1; } @@ -570,6 +574,9 @@ TWebPVSetField(TIFF* tif, uint32 tag, va_list ap) case TIFFTAG_WEBP_LOSSLESS: #if WEBP_ENCODER_ABI_VERSION >= 0x0100 sp->lossless = va_arg(ap, int); + if (sp->lossless){ + sp->quality_level = 100.0f; + } return 1; #else TIFFErrorExt(tif->tif_clientdata, module, |