image-info-from-stream
Version:
access image info from stream
46 lines (34 loc) • 1.11 kB
Markdown
# image info from stream
[](https://travis-ci.org/elcarim5efil/image-info-from-stream)
[](https://coveralls.io/github/elcarim5efil/image-info-from-stream?branch=master)
## introduction
access image size from stream.
support image file types:
- `.jpg`
- `.png`
- `.gif`
- `.bmp`
## usage
### Callback
```javascript
const getImageInfo = require('image-infor-from-stream');
const stream = fs.createReadStream('test.png');
stream.pipe(
getImageInfo(res => {
const { width, height, type } = res;
const name = `${width}x${height}.${type}`;
})
);
```
### External Object
```javascript
const getImageInfo = require('image-infor-from-stream');
const stream = fs.createReadStream('test.png');
const meta = {};
stream
.pipe(getImageInfo(meta))
.on('finish', () => {
const { width, height, type } = meta;
const name = `${width}x${height}.${type}`;
});
```