Emit post-processing 'info' event for Stream-based output

This commit is contained in:
Lovell Fuller
2016-03-01 20:08:05 +00:00
parent bb37dc1ea6
commit 86815bc9c4
4 changed files with 42 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ The object returned by the constructor implements the
[stream.Duplex](http://nodejs.org/api/stream.html#stream_class_stream_duplex) class.
JPEG, PNG or WebP format image data can be streamed out from this object.
When using Stream based output, derived attributes are available from the `info` event.
```javascript
sharp('input.jpg')
@@ -37,6 +38,19 @@ sharp('input.jpg')
});
```
```javascript
// Read image data from readableStream,
// resize to 300 pixels wide,
// emit an 'info' event with calculated dimensions
// and finally write image data to writableStream
var transformer = sharp()
.resize(300)
.on('info', function(info) {
console.log('Image height is ' + info.height);
});
readableStream.pipe(transformer).pipe(writableStream);
```
#### metadata([callback])
Fast access to image metadata without decoding any compressed image data.

View File

@@ -10,6 +10,10 @@
[#338](https://github.com/lovell/sharp/issues/338)
[@lookfirst](https://github.com/lookfirst)
* Emit post-processing 'info' event for Stream output.
[#367](https://github.com/lovell/sharp/issues/367)
[@salzhrani](https://github.com/salzhrani)
### v0.13 - "*mind*"
#### v0.13.1 - 27<sup>th</sup> February 2016