You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

is-webp

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-webp

Check if a Buffer/Uint8Array is a WebP image

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
478
-22.78%
Maintainers
1
Weekly downloads
 
Created
Source

is-webp

Check if a Buffer/Uint8Array is a WebP image

Install

npm install is-webp

Usage

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

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

isWebp(buffer);
//=> true
Browser
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.

  • file-type - Detect the file type of a Buffer/Uint8Array
  • is-webp-extended - Extended version of this package which supports checking for animated WebP

Keywords

webp

FAQs

Package last updated on 18 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts