From 8ba71c94f41bc4360845b5cc5daf086f05ba57ac Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Fri, 22 Aug 2014 14:24:01 +0100 Subject: [PATCH] Add usage example of metadata method --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 728a89b9..47ed9bb8 100755 --- a/README.md +++ b/README.md @@ -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) {