Skip to content

Commit

Permalink
The long-awaited return of code examples to README
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Oct 12, 2016
1 parent 18b9991 commit d4a1722
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# sharp

```sh
npm install sharp
```

The typical use case for this high speed Node.js module
is to convert large images in common formats to
smaller, web-friendly JPEG, PNG and WebP images of varying dimensions.
Expand All @@ -16,6 +20,43 @@ rotation, extraction, compositing and gamma correction are available.
OS X, Windows (x64), Linux (x64, ARM) systems do not require
the installation of any external runtime dependencies.

## Examples

```javascript
import sharp from 'sharp';
```

```javascript
sharp(inputBuffer)
.resize(320, 240)
.toFile('output.webp', (err, info) => ... );
```

```javascript
sharp('input.jpg')
.rotate()
.resize(200)
.toBuffer()
.then( data => ... )
.catch( err => ... );
```

```javascript
const roundedCorners = new Buffer(
'<svg><rect x="0" y="0" width="200" height="200" rx="50" ry="50"/></svg>'
);

const roundedCornerResizer =
sharp()
.resize(200, 200)
.overlayWith(roundedCorners, { cutout: true })
.png();

readableStream
.pipe(roundedCornerResizer)
.pipe(writableStream);
```

[![Test Coverage](https://coveralls.io/repos/lovell/sharp/badge.png?branch=master)](https://coveralls.io/r/lovell/sharp?branch=master)

### Documentation
Expand Down

0 comments on commit d4a1722

Please sign in to comment.