Add support for WebP and PackBits compression with TIFF output #3198

This commit is contained in:
Lovell Fuller 2022-06-29 11:35:56 +01:00
parent bb91912883
commit 7a8ab452c5
4 changed files with 8 additions and 5 deletions

View File

@ -419,7 +419,7 @@ The `density` can be set in pixels/inch via [withMetadata][1] instead of providi
* `options.quality` **[number][12]** quality, integer 1-100 (optional, default `80`) * `options.quality` **[number][12]** quality, integer 1-100 (optional, default `80`)
* `options.force` **[boolean][10]** force TIFF output, otherwise attempt to use input format (optional, default `true`) * `options.force` **[boolean][10]** force TIFF output, otherwise attempt to use input format (optional, default `true`)
* `options.compression` **[string][2]** compression options: lzw, deflate, jpeg, ccittfax4 (optional, default `'jpeg'`) * `options.compression` **[string][2]** compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k (optional, default `'jpeg'`)
* `options.predictor` **[string][2]** compression predictor options: none, horizontal, float (optional, default `'horizontal'`) * `options.predictor` **[string][2]** compression predictor options: none, horizontal, float (optional, default `'horizontal'`)
* `options.pyramid` **[boolean][10]** write an image pyramid (optional, default `false`) * `options.pyramid` **[boolean][10]** write an image pyramid (optional, default `false`)
* `options.tile` **[boolean][10]** write a tiled tiff (optional, default `false`) * `options.tile` **[boolean][10]** write a tiled tiff (optional, default `false`)

View File

@ -8,6 +8,9 @@ Requires libvips v8.13.0
* Drop support for Node.js 12, now requires Node.js >= 14.15.0. * Drop support for Node.js 12, now requires Node.js >= 14.15.0.
* Add support for WebP and PackBits `compression` options with TIFF output.
[#3198](https://github.com/lovell/sharp/issues/3198)
## v0.30 - *dresser* ## v0.30 - *dresser*
Requires libvips v8.12.2 Requires libvips v8.12.2

File diff suppressed because one or more lines are too long

View File

@ -702,7 +702,7 @@ function trySetAnimationOptions (source, target) {
* @param {Object} [options] - output options * @param {Object} [options] - output options
* @param {number} [options.quality=80] - quality, integer 1-100 * @param {number} [options.quality=80] - quality, integer 1-100
* @param {boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format * @param {boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format
* @param {string} [options.compression='jpeg'] - compression options: lzw, deflate, jpeg, ccittfax4 * @param {string} [options.compression='jpeg'] - compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k
* @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float * @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float
* @param {boolean} [options.pyramid=false] - write an image pyramid * @param {boolean} [options.pyramid=false] - write an image pyramid
* @param {boolean} [options.tile=false] - write a tiled tiff * @param {boolean} [options.tile=false] - write a tiled tiff
@ -770,10 +770,10 @@ function tiff (options) {
} }
// compression // compression
if (is.defined(options.compression)) { if (is.defined(options.compression)) {
if (is.string(options.compression) && is.inArray(options.compression, ['lzw', 'deflate', 'jpeg', 'ccittfax4', 'none'])) { if (is.string(options.compression) && is.inArray(options.compression, ['none', 'jpeg', 'deflate', 'packbits', 'ccittfax4', 'lzw', 'webp', 'zstd', 'jp2k'])) {
this.options.tiffCompression = options.compression; this.options.tiffCompression = options.compression;
} else { } else {
throw is.invalidParameterError('compression', 'one of: lzw, deflate, jpeg, ccittfax4, none', options.compression); throw is.invalidParameterError('compression', 'one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k', options.compression);
} }
} }
// predictor // predictor