# is-webp

> Check if a Buffer/Uint8Array is a WebP image

Latest version **2.0.0** (published 2021-09-18) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-09-18 |
| First published | 2014-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | webp, google, weppy, network, graphics, image, img, pic, picture, photo, type, detect, check, is, exif, binary, buffer, uint8array |

## Links

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

## 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

- 2.0.0 (latest) — 2021-09-18
- 1.0.1 — 2018-03-22
- 1.0.0 — 2014-08-14
- 0.1.1 — 2014-04-29
- 0.1.0 — 2014-04-21

## README

# is-webp

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

## Install

```sh
npm install is-webp
```

## Usage

##### Node.js

```js
import {readChunk} from 'read-chunk';
import isWebp from 'is-webp';

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

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

##### Browser

```js
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.webp');
xhr.responseType = 'arraybuffer';

xhr.onload = () => {
	isWebp(new Uint8Array(this.response));
	//=> true
};

xhr.send();
```

## API

### isWebp(buffer)

Accepts a `Buffer` (Node.js) or `Uint8Array`.

It only needs the first 12 bytes.

## Related

- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array
- [is-webp-extended](https://github.com/mooyoul/is-webp-extended) - Extended version of this package which supports checking for animated WebP

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