# @cwasm/lodepng

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

Latest version **0.1.9** (published 2025-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cwasm/lodepng
pnpm add @cwasm/lodepng
yarn add @cwasm/lodepng
bun add @cwasm/lodepng
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.9 |
| Published | 2025-11-05 |
| First published | 2018-10-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 1 |
| Unpacked size | 71.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 36 |
| Maintainers | linusu |

## Links

- npm: https://www.npmjs.com/package/@cwasm/lodepng
- Repository: https://github.com/LinusU/cwasm-lodepng
- Homepage: https://github.com/LinusU/cwasm-lodepng#readme
- Issues: https://github.com/LinusU/cwasm-lodepng/issues
- npm.io page: https://npm.io/package/@cwasm/lodepng

## Dependencies (1)

- [@canvas/image-data](https://npm.io/package/@canvas/image-data.md) ^1.0.0

## Recent versions

- 0.1.9 (latest) — 2025-11-05
- 0.1.8 — 2025-11-05
- 0.1.7 — 2022-09-26
- 0.1.6 — 2021-10-27
- 0.1.5 — 2021-10-27
- 0.1.4 — 2020-04-13
- 0.1.3 — 2019-12-11
- 0.1.2 — 2019-11-23
- 0.1.1 — 2019-04-02
- 0.1.0 — 2018-10-13

## README

# LodePNG

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

[LodePNG]: https://lodev.org/lodepng/
[WebAssembly]: https://webassembly.org

## Installation

```sh
npm install --save @cwasm/lodepng
```

## Usage

```js
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`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), required) - The PNG data
- returns [`ImageData`](https://developer.mozilla.org/en-US/docs/Web/API/ImageData) - Decoded width, height and pixel data

### `encode(source)`

- `source` (`ImageLike`, required) - The image data
- returns [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) - Encoded data

---
_Source: https://npm.io/package/@cwasm/lodepng · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
