@cwasm/lodepng
TypeScript icon, indicating that this package has built-in type declarations

0.1.7 • Public • Published

LodePNG

PNG decoding/encoding for Node.js, using LodePNG compiled to WebAssembly.

Installation

npm install --save @cwasm/lodepng

Usage

const fs = require('fs')
const lodepng = require('@cwasm/lodepng')

const source = fs.readFileSync('image.png')
const image = lodepng.decode(source)

console.log(image)
// { width: 128,
//   height: 128,
//   data:
//    Uint8ClampedArray [ ... ] }

const data = lodepng.encode(image)

console.log(data)
// Uint8Array [ 137, 80, 78, 71, ... ]

API

decode(source)

  • source (Uint8Array, required) - The PNG data
  • returns ImageData - Decoded width, height and pixel data

encode(source)

  • source (ImageLike, required) - The image data
  • returns Uint8Array - Encoded data

Readme

Keywords

none

Package Sidebar

Install

npm i @cwasm/lodepng

Weekly Downloads

4,704

Version

0.1.7

License

MIT

Unpacked Size

63 kB

Total Files

5

Last publish

Collaborators

  • linusu