is-bmp
Check if a Buffer/Uint8Array is a BMP image
Last updated 5 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install is-bmp 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.0.0                                ...           latest (5 years ago)

5 Versions

  • 2.0.0                                ...           5 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           12 years ago
  • 0.1.1                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 2
Last Day 0
Last Week 1
Last Month 1
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |