mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Document new extract method
This commit is contained in:
parent
945d941c7b
commit
b7bbf58624
26
README.md
26
README.md
@ -168,6 +168,22 @@ http.createServer(function(request, response) {
|
|||||||
// resized to 200 pixels wide, in WebP format
|
// resized to 200 pixels wide, in WebP format
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
sharp(input)
|
||||||
|
.extract(top, left, width, height)
|
||||||
|
.toFile(output);
|
||||||
|
// Extract a region of the input image, saving in the same format.
|
||||||
|
```
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
sharp(input)
|
||||||
|
.extract(topOffsetPre, leftOffsetPre, widthPre, heightPre)
|
||||||
|
.resize(width, height)
|
||||||
|
.extract(topOffsetPost, leftOffsetPost, widthPost, heightPost)
|
||||||
|
.toFile(output);
|
||||||
|
// Extract a region, resize, then extract from the resized image
|
||||||
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
sharp(inputBuffer)
|
sharp(inputBuffer)
|
||||||
.resize(200, 300)
|
.resize(200, 300)
|
||||||
@ -255,6 +271,16 @@ Scale output to `width` x `height`. By default, the resized image is cropped to
|
|||||||
|
|
||||||
`height` is the Number of pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.
|
`height` is the Number of pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.
|
||||||
|
|
||||||
|
#### extract(top, left, width, height)
|
||||||
|
|
||||||
|
Extract a region of the image. Can be used with or without a `resize` operation.
|
||||||
|
|
||||||
|
`top` and `left` are the offset, in pixels, from the top-left corner.
|
||||||
|
|
||||||
|
`width` and `height` are the dimensions of the extracted image.
|
||||||
|
|
||||||
|
Use `extract` before `resize` for pre-resize extraction. Use `extract` after `resize` for post-resize extraction. Use `extract` before and after for both.
|
||||||
|
|
||||||
#### crop([gravity])
|
#### crop([gravity])
|
||||||
|
|
||||||
Crop the resized image to the exact size specified, the default behaviour.
|
Crop the resized image to the exact size specified, the default behaviour.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user