Add usage example of metadata method

This commit is contained in:
Lovell Fuller 2014-08-22 14:24:01 +01:00
parent f2f3eb76e1
commit 8ba71c94f4

View File

@ -100,6 +100,15 @@ readableStream.pipe(transformer).pipe(writableStream);
// Read image data from readableStream, resize and write image data to 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 ```javascript
var pipeline = sharp().rotate().resize(null, 200).progressive().toBuffer(function(err, outputBuffer, info) { var pipeline = sharp().rotate().resize(null, 200).progressive().toBuffer(function(err, outputBuffer, info) {
if (err) { if (err) {