Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/LinusU/node-lodepng
LodePNG Node.js bindings
https://github.com/LinusU/node-lodepng
Last synced: 16 days ago
JSON representation
LodePNG Node.js bindings
- Host: GitHub
- URL: https://github.com/LinusU/node-lodepng
- Owner: LinusU
- Created: 2015-08-30T20:00:15.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-09-11T15:21:07.000Z (2 months ago)
- Last Synced: 2024-10-20T00:48:49.005Z (25 days ago)
- Language: C
- Size: 225 KB
- Stars: 4
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# LodePNG Node.js bindings
Bindings for LodePNG which decodes and encodes PNG images.
## Installation
```sh
npm install --save lodepng
```## Usage
```javascript
const fs = require('fs')
const png = require('lodepng')/** Decoding **/
const src = fs.readFileSync('test.png')
png.decode(src).then((res) => {
console.log(`Image size: ${res.width}x${res.height}`)
// res.data is a Buffer with RGBA data
})/** Encoding **/
const data = fs.readFileSync('test.raw')
png.encode({ width: 16, height: 16, data }).then((res) => {
// res is a Buffer with PNG data
})
```## API
### `png.decode(source) => Promise`
Decode PNG data to raw RGBA buffer.
### `png.encode(source) => Promise`
Encode raw RGBA buffer to PNG data.