PNG decoding for Node.js, using LodePNG compiled to WebAssembly
PNG decoding/encoding for Node.js, using LodePNG compiled to WebAssembly.
npm install --save @cwasm/lodepng
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, ... ]
decode(source)source (Uint8Array, required) - The PNG dataImageData - Decoded width, height and pixel dataencode(source)source (ImageLike, required) - The image dataUint8Array - Encoded data