mirror of
https://github.com/lovell/sharp.git
synced 2025-12-18 23:05:04 +01:00
Expose optional minAmplitude parameter of blur operation (#4172)
This commit is contained in:
committed by
GitHub
parent
67a5854b89
commit
735fee74db
@@ -227,6 +227,7 @@ const Sharp = function (input, options) {
|
||||
medianSize: 0,
|
||||
blurSigma: 0,
|
||||
precision: 'integer',
|
||||
minAmpl: 0.2,
|
||||
sharpenSigma: 0,
|
||||
sharpenM1: 1,
|
||||
sharpenM2: 2,
|
||||
|
||||
2
lib/index.d.ts
vendored
2
lib/index.d.ts
vendored
@@ -1347,6 +1347,8 @@ declare namespace sharp {
|
||||
interface BlurOptions {
|
||||
/** A value between 0.3 and 1000 representing the sigma of the Gaussian mask, where `sigma = 1 + radius / 2` */
|
||||
sigma: number;
|
||||
/** A value between 0.001 and 1. A smaller value will generate a larger, more accurate mask. */
|
||||
minAmplitude?: number;
|
||||
/** How accurate the operation should be, one of: integer, float, approximate. (optional, default "integer") */
|
||||
precision?: Precision | undefined;
|
||||
}
|
||||
|
||||
@@ -381,6 +381,7 @@ function median (size) {
|
||||
* @param {Object|number|Boolean} [options]
|
||||
* @param {number} [options.sigma] a value between 0.3 and 1000 representing the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`.
|
||||
* @param {string} [options.precision='integer'] How accurate the operation should be, one of: integer, float, approximate.
|
||||
* @param {number} [options.minAmplitude=0.2] A value between 0.001 and 1. A smaller value will generate a larger, more accurate mask.
|
||||
* @returns {Sharp}
|
||||
* @throws {Error} Invalid parameters
|
||||
*/
|
||||
@@ -400,6 +401,13 @@ function blur (options) {
|
||||
throw is.invalidParameterError('precision', 'one of: integer, float, approximate', options.precision);
|
||||
}
|
||||
}
|
||||
if ('minAmplitude' in options) {
|
||||
if (is.number(options.minAmplitude) && is.inRange(options.minAmplitude, 0.001, 1)) {
|
||||
this.options.minAmpl = options.minAmplitude;
|
||||
} else {
|
||||
throw is.invalidParameterError('minAmplitude', 'number between 0.001 and 1', options.minAmplitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is.defined(options)) {
|
||||
|
||||
Reference in New Issue
Block a user