# pngparse

> convert PNG images to pixel arrays without dependencies

Latest version **2.0.1** (published 2013-06-20) · 0 weekly downloads

## Install

```sh
npm install pngparse
pnpm add pngparse
yarn add pngparse
bun add pngparse
```

## 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 | 2.0.1 |
| Published | 2013-06-20 |
| First published | 2012-11-20 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 78 |
| Author | The Dark Sky Company |
| Maintainers | darkskyapp |
| Keywords | png, image |

## Links

- npm: https://www.npmjs.com/package/pngparse
- Repository: https://github.com/darkskyapp/pngparse
- npm.io page: https://npm.io/package/pngparse

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2013-06-20
- 2.0.0 — 2013-06-10
- 1.1.4 — 2013-05-06
- 1.1.2 — 2012-11-30
- 1.1.1 — 2012-11-29
- 1.0.2 — 2012-11-28
- 1.0.0 — 2012-11-20

## README

pngparse
========

`pngparse` is a pure-JavaScript library for [Node.JS](http://nodejs.org/) for
converting a PNG file into an array of pixel values. It came out of a need for
reading PNG images in Node.JS for the [Dark Sky
API](http://developer.darkskyapp.com/), but all existing libraries either had
compilation issues or did not support enough of the PNG standard to be
practical.

There's a reason nobody writes PNG-parsing libraries. This stuff is complicated
and reinventing the wheel is dumb. But, if you're wondering whether you can
trust it, it has a full unit test suite and we've been using it in production
since Sep 2012, so there you go.

It's reasonably complete, covering most PNG color types, depths, and filters;
notable omissions are lack of support for 16-bit images and interlacing.

Comments, bug fixes, feature improvements, etc. are all welcome. If you do
write code, please ensure that you write tests for it!

Usage
-----

To install:

    npm install pngparse

To use:

    var pngparse = require("pngparse")

    ...

    pngparse.parse(buffer, function(err, data) {
      if(err)
        throw err

      /* do things! */
    })

    ...

    pngparse.parseFile("path/to/file.png", function(err, data) {
      if(err)
        throw err

      /* do things! */
    })

The `data` object returned from the callback bears a striking resemblance to
the [HTML5 Canvas ImageData
object](https://developer.mozilla.org/en-US/docs/DOM/ImageData). A notable
distinction is that the object returns has a `channels` property which
indicates how many color channels it uses (while an HTML5 ImageData object is
always 4-channel). The possible color channel combinations are as follows:

    1 channel : grayscale
    2 channels: grayscale + alpha
    3 channels: RGB
    4 channels: RGBA

If you use the `ImageData.prototype.getPixel` method, this is handled for you;
however, if you access the `data` array manually, then you will have to be
aware of it.

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