Remove previously-deprecated properties from API

This commit is contained in:
Lovell Fuller
2025-12-29 13:04:27 +00:00
parent 937167933b
commit 1b2f79335d
13 changed files with 31 additions and 134 deletions

32
lib/index.d.ts vendored
View File

@@ -259,7 +259,6 @@ declare namespace sharp {
* Set the pipeline colourspace.
* The input image will be converted to the provided colourspace at the start of the pipeline.
* All operations will use this colourspace before converting to the output colourspace, as defined by toColourspace.
* This feature is experimental and has not yet been fully-tested with all operations.
*
* @param colourspace pipeline colourspace e.g. rgb16, scrgb, lab, grey16 ...
* @throws {Error} Invalid parameters
@@ -470,21 +469,6 @@ declare namespace sharp {
*/
sharpen(options?: SharpenOptions): Sharp;
/**
* Sharpen the image.
* When used without parameters, performs a fast, mild sharpen of the output image.
* When a sigma is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.
* Fine-grained control over the level of sharpening in "flat" (m1) and "jagged" (m2) areas is available.
* @param sigma the sigma of the Gaussian mask, where sigma = 1 + radius / 2.
* @param flat the level of sharpening to apply to "flat" areas. (optional, default 1.0)
* @param jagged the level of sharpening to apply to "jagged" areas. (optional, default 2.0)
* @throws {Error} Invalid parameters
* @returns A sharp instance that can be used to chain operations
*
* @deprecated Use the object parameter `sharpen({sigma, m1, m2, x1, y2, y3})` instead
*/
sharpen(sigma?: number, flat?: number, jagged?: number): Sharp;
/**
* Apply median filter. When used without parameters the default window is 3x3.
* @param size square mask size: size x size (optional, default 3)
@@ -910,7 +894,7 @@ declare namespace sharp {
* - sharp.gravity: north, northeast, east, southeast, south, southwest, west, northwest, center or centre.
* - sharp.strategy: cover only, dynamically crop using either the entropy or attention strategy. Some of these values are based on the object-position CSS property.
*
* The experimental strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
* The strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
* discarding the edge with the lowest score based on the selected strategy.
* - entropy: focus on the region with the highest Shannon entropy.
* - attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
@@ -999,14 +983,6 @@ declare namespace sharp {
* 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort. (optional, default 'warning')
*/
failOn?: FailOnOptions | undefined;
/**
* By default halt processing and raise an error when loading invalid images.
* Set this flag to false if you'd rather apply a "best effort" to decode images,
* even if the data is corrupt or invalid. (optional, default true)
*
* @deprecated Use `failOn` instead
*/
failOnError?: boolean | undefined;
/**
* Do not process input images where the number of pixels (width x height) exceeds this limit.
* Assumes image dimensions contained in the input metadata can be trusted.
@@ -1308,11 +1284,11 @@ declare namespace sharp {
channels: ChannelStats[];
/** Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel */
isOpaque: boolean;
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any (experimental) */
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any */
entropy: number;
/** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any (experimental) */
/** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any */
sharpness: number;
/** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram (experimental) */
/** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram */
dominant: { r: number; g: number; b: number };
}

View File

@@ -30,7 +30,7 @@ const inputStreamParameters = [
// Format-specific
'jp2', 'openSlide', 'pdf', 'raw', 'svg', 'tiff',
// Deprecated
'failOnError', 'openSlideLevel', 'pdfBackground', 'tiffSubifd'
'openSlideLevel', 'pdfBackground', 'tiffSubifd'
];
/**
@@ -106,14 +106,6 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
}`);
}
if (is.object(inputOptions)) {
// Deprecated: failOnError
if (is.defined(inputOptions.failOnError)) {
if (is.bool(inputOptions.failOnError)) {
inputDescriptor.failOn = inputOptions.failOnError ? 'warning' : 'none';
} else {
throw is.invalidParameterError('failOnError', 'boolean', inputOptions.failOnError);
}
}
// failOn
if (is.defined(inputOptions.failOn)) {
if (is.string(inputOptions.failOn) && is.inArray(inputOptions.failOn, ['none', 'truncated', 'error', 'warning'])) {

View File

@@ -259,45 +259,18 @@ function affine (matrix, options) {
* })
* .toBuffer();
*
* @param {Object|number} [options] - if present, is an Object with attributes
* @param {Object} [options] - if present, is an Object with attributes
* @param {number} [options.sigma] - the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10
* @param {number} [options.m1=1.0] - the level of sharpening to apply to "flat" areas, between 0 and 1000000
* @param {number} [options.m2=2.0] - the level of sharpening to apply to "jagged" areas, between 0 and 1000000
* @param {number} [options.x1=2.0] - threshold between "flat" and "jagged", between 0 and 1000000
* @param {number} [options.y2=10.0] - maximum amount of brightening, between 0 and 1000000
* @param {number} [options.y3=20.0] - maximum amount of darkening, between 0 and 1000000
* @param {number} [flat] - (deprecated) see `options.m1`.
* @param {number} [jagged] - (deprecated) see `options.m2`.
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
function sharpen (options, flat, jagged) {
if (!is.defined(options)) {
// No arguments: default to mild sharpen
this.options.sharpenSigma = -1;
} else if (is.bool(options)) {
// Deprecated boolean argument: apply mild sharpen?
this.options.sharpenSigma = options ? -1 : 0;
} else if (is.number(options) && is.inRange(options, 0.01, 10000)) {
// Deprecated numeric argument: specific sigma
this.options.sharpenSigma = options;
// Deprecated control over flat areas
if (is.defined(flat)) {
if (is.number(flat) && is.inRange(flat, 0, 10000)) {
this.options.sharpenM1 = flat;
} else {
throw is.invalidParameterError('flat', 'number between 0 and 10000', flat);
}
}
// Deprecated control over jagged areas
if (is.defined(jagged)) {
if (is.number(jagged) && is.inRange(jagged, 0, 10000)) {
this.options.sharpenM2 = jagged;
} else {
throw is.invalidParameterError('jagged', 'number between 0 and 10000', jagged);
}
}
} else if (is.plainObject(options)) {
function sharpen (options) {
if (is.plainObject(options)) {
if (is.number(options.sigma) && is.inRange(options.sigma, 0.000001, 10)) {
this.options.sharpenSigma = options.sigma;
} else {
@@ -339,7 +312,7 @@ function sharpen (options, flat, jagged) {
}
}
} else {
throw is.invalidParameterError('sigma', 'number between 0.01 and 10000', options);
this.options.sharpenSigma = -1;
}
return this;
}
@@ -510,8 +483,6 @@ function flatten (options) {
*
* Existing alpha channel values for non-white pixels remain unchanged.
*
* This feature is experimental and the API may change.
*
* @since 0.32.1
*
* @example

View File

@@ -1151,8 +1151,7 @@ function tiff (options) {
* AVIF image sequences are not supported.
* Prebuilt binaries support a bitdepth of 8 only.
*
* This feature is experimental on the Windows ARM64 platform
* and requires a CPU with ARM64v8.4 or later.
* When using Windows ARM64, this feature requires a CPU with ARM64v8.4 or later.
*
* @example
* const data = await sharp(input)