Add support for miniswhite when using TIFF output

This commit is contained in:
Dennis Beatty
2023-09-26 14:38:34 +01:00
committed by Lovell Fuller
parent 0f24f0f214
commit 28aa176957
9 changed files with 29 additions and 2 deletions

View File

@@ -305,6 +305,7 @@ const Sharp = function (input, options) {
tiffCompression: 'jpeg',
tiffPredictor: 'horizontal',
tiffPyramid: false,
tiffMiniswhite: false,
tiffBitdepth: 8,
tiffTile: false,
tiffTileHeight: 256,

2
lib/index.d.ts vendored
View File

@@ -1234,6 +1234,8 @@ declare namespace sharp {
yres?: number | undefined;
/** Reduce bitdepth to 1, 2 or 4 bit (optional, default 8) */
bitdepth?: 1 | 2 | 4 | 8 | undefined;
/** Write 1-bit images as miniswhite (optional, default false) */
miniswhite?: boolean | undefined;
/** Resolution unit options: inch, cm (optional, default 'inch') */
resolutionUnit?: 'inch' | 'cm' | undefined;
}

View File

@@ -782,6 +782,7 @@ function trySetAnimationOptions (source, target) {
* @param {number} [options.yres=1.0] - vertical resolution in pixels/mm
* @param {string} [options.resolutionUnit='inch'] - resolution unit options: inch, cm
* @param {number} [options.bitdepth=8] - reduce bitdepth to 1, 2 or 4 bit
* @param {boolean} [options.miniswhite=false] - write 1-bit images as miniswhite
* @returns {Sharp}
* @throws {Error} Invalid options
*/
@@ -819,6 +820,10 @@ function tiff (options) {
throw is.invalidParameterError('tileHeight', 'integer greater than zero', options.tileHeight);
}
}
// miniswhite
if (is.defined(options.miniswhite)) {
this._setBooleanOption('tiffMiniswhite', options.miniswhite);
}
// pyramid
if (is.defined(options.pyramid)) {
this._setBooleanOption('tiffPyramid', options.pyramid);