mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Switch from custom trim op to vips_find_trim #914
This commit is contained in:
@@ -359,18 +359,18 @@ function extract (options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim "boring" pixels from all edges that contain values within a percentage similarity of the top-left pixel.
|
||||
* @param {Number} [tolerance=10] value between 1 and 99 representing the percentage similarity.
|
||||
* Trim "boring" pixels from all edges that contain values similar to the top-left pixel.
|
||||
* @param {Number} [threshold=10] the allowed difference from the top-left pixel, a number greater than zero.
|
||||
* @returns {Sharp}
|
||||
* @throws {Error} Invalid parameters
|
||||
*/
|
||||
function trim (tolerance) {
|
||||
if (!is.defined(tolerance)) {
|
||||
this.options.trimTolerance = 10;
|
||||
} else if (is.integer(tolerance) && is.inRange(tolerance, 1, 99)) {
|
||||
this.options.trimTolerance = tolerance;
|
||||
function trim (threshold) {
|
||||
if (!is.defined(threshold)) {
|
||||
this.options.trimThreshold = 10;
|
||||
} else if (is.number(threshold) && threshold > 0) {
|
||||
this.options.trimThreshold = threshold;
|
||||
} else {
|
||||
throw new Error('Invalid trim tolerance (1 to 99) ' + tolerance);
|
||||
throw is.invalidParameterError('threshold', 'number greater than zero', threshold);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user