lodepng

Bindings for LodePNG which decodes and encodes PNG images.

Zlib 14 个版本
安装
npm install lodepng
yarn add lodepng
pnpm add lodepng
bun add lodepng
README

LodePNG Node.js bindings

Bindings for LodePNG which decodes and encodes PNG images.

Installation

npm install --save lodepng

Usage

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.

版本列表
2.3.0 2024-09-11
2.2.0 2023-02-01
2.1.0 2021-10-27
2.0.0 2019-11-09
1.3.0 2019-11-08
1.2.0 2018-08-08
1.1.0 2017-08-20
1.0.0 2017-08-17
0.2.3 2017-08-17
0.2.2 2016-05-10
0.2.1 2016-05-10
0.2.0 2015-10-20
0.1.1 2015-08-30
0.1.0 2015-08-30