mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Add usage example of metadata method
This commit is contained in:
parent
f2f3eb76e1
commit
8ba71c94f4
@ -100,6 +100,15 @@ readableStream.pipe(transformer).pipe(writableStream);
|
||||
// Read image data from readableStream, resize and write image data to writableStream
|
||||
```
|
||||
|
||||
```javascript
|
||||
var image = sharp(inputJpg);
|
||||
image.metadata(function(err, metadata) {
|
||||
image.resize(metadata.width / 2).webp().toBuffer(function(err, outputBuffer, info) {
|
||||
// outputBuffer contains a WebP image half the width and height of the original JPEG
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
```javascript
|
||||
var pipeline = sharp().rotate().resize(null, 200).progressive().toBuffer(function(err, outputBuffer, info) {
|
||||
if (err) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user