mirror of
https://github.com/lovell/sharp.git
synced 2026-02-04 05:36:18 +01:00
Ensure TIFF output bitdepth option is limited to 1, 2 or 4
This commit is contained in:
@@ -366,7 +366,7 @@ const Sharp = function (input, options) {
|
||||
tiffPredictor: 'horizontal',
|
||||
tiffPyramid: false,
|
||||
tiffMiniswhite: false,
|
||||
tiffBitdepth: 8,
|
||||
tiffBitdepth: 0,
|
||||
tiffTile: false,
|
||||
tiffTileHeight: 256,
|
||||
tiffTileWidth: 256,
|
||||
|
||||
4
lib/index.d.ts
vendored
4
lib/index.d.ts
vendored
@@ -1479,8 +1479,8 @@ declare namespace sharp {
|
||||
xres?: number | undefined;
|
||||
/** Vertical resolution in pixels/mm (optional, default 1.0) */
|
||||
yres?: number | undefined;
|
||||
/** Reduce bitdepth to 1, 2 or 4 bit (optional, default 8) */
|
||||
bitdepth?: 1 | 2 | 4 | 8 | undefined;
|
||||
/** Reduce bitdepth to 1, 2 or 4 bit (optional) */
|
||||
bitdepth?: 1 | 2 | 4 | undefined;
|
||||
/** Write 1-bit images as miniswhite (optional, default false) */
|
||||
miniswhite?: boolean | undefined;
|
||||
/** Resolution unit options: inch, cm (optional, default 'inch') */
|
||||
|
||||
@@ -1055,7 +1055,7 @@ function trySetAnimationOptions (source, target) {
|
||||
* @param {number} [options.xres=1.0] - horizontal resolution in pixels/mm
|
||||
* @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 {number} [options.bitdepth=0] - 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
|
||||
@@ -1070,10 +1070,10 @@ function tiff (options) {
|
||||
}
|
||||
}
|
||||
if (is.defined(options.bitdepth)) {
|
||||
if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4, 8])) {
|
||||
if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4])) {
|
||||
this.options.tiffBitdepth = options.bitdepth;
|
||||
} else {
|
||||
throw is.invalidParameterError('bitdepth', '1, 2, 4 or 8', options.bitdepth);
|
||||
throw is.invalidParameterError('bitdepth', '1, 2 or 4', options.bitdepth);
|
||||
}
|
||||
}
|
||||
// tiling
|
||||
|
||||
Reference in New Issue
Block a user