mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Docs: add more examples (composite, greyscale, tint)
This commit is contained in:
@@ -9,7 +9,13 @@ An alpha channel may be present and will be unchanged by the operation.
|
||||
|
||||
* `rgb` **([string][1] | [Object][2])** parsed by the [color][3] module to extract chroma values.
|
||||
|
||||
<!---->
|
||||
### Examples
|
||||
|
||||
```javascript
|
||||
const output = await sharp(input)
|
||||
.tint({ r: 255, g: 240, b: 16 })
|
||||
.toBuffer();
|
||||
```
|
||||
|
||||
* Throws **[Error][4]** Invalid parameter
|
||||
|
||||
@@ -28,6 +34,12 @@ An alpha channel may be present, and will be unchanged by the operation.
|
||||
|
||||
* `greyscale` **[Boolean][5]** (optional, default `true`)
|
||||
|
||||
### Examples
|
||||
|
||||
```javascript
|
||||
const output = await sharp(input).greyscale().toBuffer();
|
||||
```
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
## grayscale
|
||||
|
||||
@@ -46,6 +46,23 @@ and [https://www.cairographics.org/operators/][2]
|
||||
|
||||
### Examples
|
||||
|
||||
```javascript
|
||||
await sharp(background)
|
||||
.composite([
|
||||
{ input: layer1, gravity: 'northwest' },
|
||||
{ input: layer2, gravity: 'southeast' },
|
||||
])
|
||||
.toFile('combined.png');
|
||||
```
|
||||
|
||||
```javascript
|
||||
const output = await sharp('input.gif', { animated: true })
|
||||
.composite([
|
||||
{ input: 'overlay.png', tile: true, blend: 'saturate' }
|
||||
])
|
||||
.toBuffer();
|
||||
```
|
||||
|
||||
```javascript
|
||||
sharp('input.png')
|
||||
.rotate(180)
|
||||
|
||||
Reference in New Issue
Block a user