# png-stream

> A streaming PNG encoder and decoder

Latest version **1.0.5** (published 2016-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install png-stream
pnpm add png-stream
yarn add png-stream
bun add png-stream
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2016-11-10 |
| First published | 2014-11-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Devon Govett |
| Maintainers | devongovett |
| Keywords | pixel-stream, image, decode, encode, codec, png |

## Links

- npm: https://www.npmjs.com/package/png-stream
- Repository: https://github.com/devongovett/png-stream
- Issues: https://github.com/devongovett/png-stream/issues
- npm.io page: https://npm.io/package/png-stream

## Dependencies (4)

- [bl](https://npm.io/package/bl.md) ^0.9.3
- [buffer-crc32](https://npm.io/package/buffer-crc32.md) ^0.2.3
- [buffer-equal](https://npm.io/package/buffer-equal.md) ^0.0.1
- [pixel-stream](https://npm.io/package/pixel-stream.md) ^1.0.3

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2016-11-10
- 1.0.4 — 2015-02-09
- 1.0.3 — 2015-02-09
- 1.0.2 — 2015-02-04
- 1.0.1 — 2014-11-19
- 1.0.0 — 2014-11-17

## README

# png-stream

A streaming PNG encoder and decoder for Node and the browser.
Supports [animated PNGs](https://wiki.mozilla.org/APNG_Specification) and
normal still PNGs.

## Installation

    npm png-stream

For the browser, you can build using [Browserify](http://browserify.org/).

## Decoding

This example uses the [concat-frames](https://github.com/devongovett/concat-frames)
module to collect the output of the PNG decoder into an array of frame objects.

```javascript
var PNGDecoder = require('png-stream/decoder');
var concat = require('concat-frames');

// decode a PNG file to RGB pixels
fs.createReadStream('in.png')
  .pipe(new PNGDecoder)
  .pipe(concat(function(frames) {
    // frames is an array of frame objects
    // each one has a `pixels` property containing
    // the raw RGB pixel data for that frame, as
    // well as the width, height, etc.
  }));
```

## Encoding

You can encode a PNG by writing or piping pixel data to a `PNGEncoder` stream.
The PNG encoder supports writing data in the RGB, RGBA, grayscale (`gray`), 
and grayscale + alpha (`gray`) color spaces.  You can also write data in the
`indexed` color space by first quantizing it using the [neuquant](https://github.com/devongovett/neuquant)
module.

```javascript
var PNGEncoder = require('png-stream/encoder');
var neuquant = require('neuquant');

// convert a JPEG to a PNG
fs.createReadStream('in.jpg')
  .pipe(new JPEGDecoder)
  .pipe(new PNGEncoder)
  .pipe(fs.createWriteStream('out.png'));
  
// write indexed data
fs.createReadStream('in.jpg')
  .pipe(new JPEGDecoder)
  .pipe(new neuquant.Stream)
  .pipe(new PNGEncoder)
  .pipe(fs.createWriteStream('indexed.png'));
```

## License

MIT

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