https://github.com/dy/image-decode
Decode image data from any image format
https://github.com/dy/image-decode
Last synced: 9 months ago
JSON representation
Decode image data from any image format
- Host: GitHub
- URL: https://github.com/dy/image-decode
- Owner: dy
- Created: 2018-11-09T19:39:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T05:03:28.000Z (almost 3 years ago)
- Last Synced: 2025-08-24T11:11:38.089Z (10 months ago)
- Language: JavaScript
- Size: 261 KB
- Stars: 25
- Watchers: 2
- Forks: 7
- Open Issues: 9
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# image-decode [](http://github.com/badges/stability-badges) [](https://travis-ci.org/dy/image-decode)
Decode image data from raw encoded binary data in any image format: PNG, GIF, BMP, JPEG, TIFF.
## Usage
[](https://npmjs.org/package/image-decode/)
```js
let decode = require('image-decode')
let {data, width, height} = decode(fs.readFileSync('./data.png'))
```
## API
### `let {data, width, height} = decode(buffer, mimeType?)`
Takes input `buffer` with encoded image data and decodes its contents, returns pixels `data` array with layout `[r, g, b, a, r, g, b, a, ...]`. `mimeType` can be passed to skip image type detection.
`buffer` can be any binary data container:
* ArrayBuffer
* Buffer
* Uint8Array
* base64 string
## See also
* [image-encode](https://ghub.io/image-encode) − encode pixels data to target format.
* [image-equal](https://ghub.io/image-equal) − image data comparing tool.
* [image-pixels](https://ghub.io/image-pixels) − load or save pixel data from/to any source.
* [image-save](https://ghub.io/image-save) − save image pixels data to a target.
* [image-type](https://ghub.io/image-type) − detect input image data type.
## Credits
© 2018 Dmitry Yv. MIT License.