Expand linear operation to allow use of per-channel arrays #3303

This commit is contained in:
Anton Marsden
2022-07-23 21:33:44 +12:00
committed by Lovell Fuller
parent b9261c243c
commit 74e3f73934
10 changed files with 104 additions and 34 deletions

View File

@@ -466,14 +466,32 @@ Returns **Sharp** 
## linear
Apply the linear formula a \* input + b to the image (levels adjustment)
Apply the linear formula `a` \* input + `b` to the image to adjust image levels.
When a single number is provided, it will be used for all image channels.
When an array of numbers is provided, the array length must match the number of channels.
### Parameters
* `a` **[number][1]** multiplier (optional, default `1.0`)
* `b` **[number][1]** offset (optional, default `0.0`)
* `a` **([number][1] | [Array][7]<[number][1]>)** multiplier (optional, default `[]`)
* `b` **([number][1] | [Array][7]<[number][1]>)** offset (optional, default `[]`)
<!---->
### Examples
```javascript
await sharp(input)
.linear(0.5, 2)
.toBuffer();
```
```javascript
await sharp(rgbInput)
.linear(
[0.25, 0.5, 0.75],
[150, 100, 50]
)
.toBuffer();
```
* Throws **[Error][5]** Invalid parameters

File diff suppressed because one or more lines are too long