Skip to content

Commit

Permalink
Reduce sharpen op max sigma from 10000 to 10 #3521
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Jan 10, 2023
1 parent ef849fd commit 081debd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/api-operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ See [libvips sharpen](https://www.libvips.org/API/current/libvips-convolution.ht
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [options] | <code>Object</code> \| <code>number</code> | | if present, is an Object with attributes |
| [options.sigma] | <code>number</code> | | the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10000 |
| [options.sigma] | <code>number</code> | | the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10 |
| [options.m1] | <code>number</code> | <code>1.0</code> | the level of sharpening to apply to "flat" areas, between 0 and 1000000 |
| [options.m2] | <code>number</code> | <code>2.0</code> | the level of sharpening to apply to "jagged" areas, between 0 and 1000000 |
| [options.x1] | <code>number</code> | <code>2.0</code> | threshold between "flat" and "jagged", between 0 and 1000000 |
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/sharpen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 081debd

Please sign in to comment.