diff --git a/docs/api-operation.md b/docs/api-operation.md index 35f212fe..bfff981c 100644 --- a/docs/api-operation.md +++ b/docs/api-operation.md @@ -158,7 +158,7 @@ See [libvips sharpen](https://www.libvips.org/API/current/libvips-convolution.ht | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object \| number | | if present, is an Object with attributes | -| [options.sigma] | number | | the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10000 | +| [options.sigma] | number | | the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10 | | [options.m1] | number | 1.0 | the level of sharpening to apply to "flat" areas, between 0 and 1000000 | | [options.m2] | number | 2.0 | the level of sharpening to apply to "jagged" areas, between 0 and 1000000 | | [options.x1] | number | 2.0 | threshold between "flat" and "jagged", between 0 and 1000000 | diff --git a/docs/changelog.md b/docs/changelog.md index 00f040bd..8fc71464 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -23,6 +23,9 @@ Requires libvips v8.14.0 * Prebuilt binaries: prevent use of glib slice allocator, improves QEMU support. [#3448](https://github.com/lovell/sharp/issues/3448) +* Reduce sharpen `sigma` maximum from 10000 to 10. + [#3521](https://github.com/lovell/sharp/issues/3521) + ## v0.31 - *eagle* Requires libvips v8.13.3 diff --git a/lib/operation.js b/lib/operation.js index d21b566b..421df10f 100644 --- a/lib/operation.js +++ b/lib/operation.js @@ -232,7 +232,7 @@ function affine (matrix, options) { * .toBuffer(); * * @param {Object|number} [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 10000 + * @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 @@ -270,10 +270,10 @@ function sharpen (options, flat, jagged) { } } } else if (is.plainObject(options)) { - if (is.number(options.sigma) && is.inRange(options.sigma, 0.000001, 10000)) { + if (is.number(options.sigma) && is.inRange(options.sigma, 0.000001, 10)) { this.options.sharpenSigma = options.sigma; } else { - throw is.invalidParameterError('options.sigma', 'number between 0.000001 and 10000', options.sigma); + throw is.invalidParameterError('options.sigma', 'number between 0.000001 and 10', options.sigma); } if (is.defined(options.m1)) { if (is.number(options.m1) && is.inRange(options.m1, 0, 1000000)) { diff --git a/test/unit/sharpen.js b/test/unit/sharpen.js index 324faa21..fd8c5cd9 100644 --- a/test/unit/sharpen.js +++ b/test/unit/sharpen.js @@ -110,7 +110,7 @@ describe('Sharpen', function () { it('invalid options.sigma', () => assert.throws( () => sharp().sharpen({ sigma: -1 }), - /Expected number between 0\.000001 and 10000 for options\.sigma but received -1 of type number/ + /Expected number between 0\.000001 and 10 for options\.sigma but received -1 of type number/ )); it('invalid options.m1', () => assert.throws(