Docs: add example of using metadata and resize to scale

This commit is contained in:
Lovell Fuller
2019-12-16 21:15:49 +00:00
parent e230ce41d7
commit 703d90e663
2 changed files with 17 additions and 0 deletions

View File

@@ -114,6 +114,15 @@ sharp(input)
});
```
```javascript
const scaleByHalf = await sharp(input)
.metadata()
.then(({ width }) => sharp(input)
.resize(Math.round(width * 0.5))
.toBuffer()
);
```
- Throws **[Error][13]** Invalid parameters
Returns **Sharp**