# is-png

> Check if a Buffer/Uint8Array is a PNG image

Latest version **3.0.1** (published 2021-09-02) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2021-09-02 |
| First published | 2014-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/is-png) |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 48 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | png, portable, network, graphics, image, picture, photo, type, detect, check, is, exif, binary, buffer, uint8array |

## Links

- npm: https://www.npmjs.com/package/is-png
- Repository: https://github.com/sindresorhus/is-png
- Homepage: https://github.com/sindresorhus/is-png#readme
- Issues: https://github.com/sindresorhus/is-png/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/is-png

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2021-09-02
- 3.0.0 — 2021-04-17
- 2.0.0 — 2019-04-20
- 1.1.0 — 2017-04-16
- 1.0.0 — 2014-08-14
- 0.1.1 — 2014-04-29
- 0.1.0 — 2014-04-21

## README

# is-png

> Check if a Buffer/Uint8Array is a [PNG](https://en.wikipedia.org/wiki/Portable_Network_Graphics) image

## Install

```
$ npm install is-png
```

## Usage

##### Node.js

```js
import {readChunk} from 'read-chunk';
import isPng from 'is-png';

const buffer = await readChunk('unicorn.png', {length: 8});

isPng(buffer);
//=> true
```

##### Browser

```js
import isPng from 'is-png';

const response = await fetch('unicorn.png');
const buffer = await response.arrayBuffer();

isPng(new Uint8Array(buffer));
//=> true
```

## API

### isPng(buffer)

Accepts a Buffer (Node.js) or Uint8Array. Returns a `boolean` of whether `buffer` is a PNG image.

#### buffer

The buffer to check. It only needs the first 8 bytes.

## Related

- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array/ArrayBuffer

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