# png-utils

> Simple PNG utils

Latest version **1.0.0** (published 2019-07-24) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-07-24 |
| First published | 2019-07-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | taigah.dev@gmail.com |
| Maintainers | taigah.dev |
| Keywords | png |

## Links

- npm: https://www.npmjs.com/package/png-utils
- Repository: https://github.com/taigah/png-utils
- Homepage: https://github.com/taigah/png-utils#readme
- Issues: https://github.com/taigah/png-utils/issues
- npm.io page: https://npm.io/package/png-utils

## Dependencies (1)

- [crc](https://npm.io/package/crc.md) ^3.8.0

## Recent versions

- 1.0.0 (latest) — 2019-07-24

## README

# png-utils

Simple PNG utils

## Installation

```bash
npm i png-utils
```

## Example

Creates a 50x20 red 24-bits PNG and saves it in `uni.png` 

```javascript
const { raw24BitsToPng } = require('png-utils')
const fs = require('fs')

const width = 50
const height = 20
const data = Buffer.from(Array(width * height).fill(0).map((v,i) => {
  return [ 0xff, 0x00, 0x00 ]
}).flat())

raw24BitsToPng(data, width, height)
.then(buffer => {
  fs.writeFileSync('uni.png', buffer)
})
.catch(err => {
  console.error(err.stack)
  process.exit(1)
})
```

## Usage

### `raw24BitsToPng : Buffer`

Converts a raw 24-bits image into 24-bits PNG

Params

* rawBuffer (Buffer)
* width (Number)
* Height (Number)

Example

```javascript
const buffer = Buffer.from([
  0xff, 0x00, 0x00,
  0xff, 0x00, 0x00,
  0xff, 0x00, 0x00,
  0xff, 0x00, 0x00,
  0xff, 0x00, 0x00
])
const width = 5
const height = 1
const png = await raw24BitsToPng(buffer, width, height)
await fs.writeFile('output.png', png)
```

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