mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add 'clone' method to snapshot an instance
Cloned instances share a common input Allows multiple output Streams to use a single input Stream
This commit is contained in:
17
README.md
17
README.md
@@ -163,6 +163,15 @@ var pipeline = sharp()
|
||||
readableStream.pipe(pipeline);
|
||||
```
|
||||
|
||||
```javascript
|
||||
var pipeline = sharp().rotate();
|
||||
pipeline.clone().resize(800, 600).pipe(firstWritableStream);
|
||||
pipeline.clone().extract(20, 20, 100, 100).pipe(secondWritableStream);
|
||||
readableStream.pipe(pipeline);
|
||||
// firstWritableStream receives auto-rotated, resized readableStream
|
||||
// secondWritableStream receives auto-rotated, extracted region of readableStream
|
||||
```
|
||||
|
||||
```javascript
|
||||
sharp('input.png')
|
||||
.rotate(180)
|
||||
@@ -347,6 +356,14 @@ Do not process input images where the number of pixels (width * height) exceeds
|
||||
|
||||
`pixels` is the integral Number of pixels, with a value between 1 and the default 268402689 (0x3FFF * 0x3FFF).
|
||||
|
||||
#### clone()
|
||||
|
||||
Takes a "snapshot" of the instance, returning a new instance.
|
||||
Cloned instances inherit the input of their parent instance.
|
||||
This allows multiple output Streams
|
||||
and therefore multiple processing pipelines
|
||||
to share a single input Stream.
|
||||
|
||||
### Image transformation options
|
||||
|
||||
#### resize(width, [height])
|
||||
|
||||
Reference in New Issue
Block a user