is-bmp

2.0.0 • Public • Published

is-bmp

Check if a Buffer/Uint8Array is a BMP image

Install

$ npm install is-bmp

Usage

Node.js
import {readChunk} from 'read-chunk';
import isBmp from 'is-bmp';

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

isBmp(buffer);
//=> true
Browser
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.bmp');
xhr.responseType = 'arraybuffer';

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

xhr.send();

API

isBmp(buffer)

Accepts a Buffer (Node.js) or Uint8Array.

It only needs the first 2 bytes.

Related

  • file-type - Detect the file type of a Buffer/Uint8Array

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    2
  • 1.0.1
    12
  • 1.0.0
    0
  • 0.1.1
    983
  • 0.1.0
    1

Package Sidebar

Install

npm i is-bmp

Weekly Downloads

998

Version

2.0.0

License

MIT

Unpacked Size

2.82 kB

Total Files

4

Last publish

Collaborators

  • sindresorhus