is-bmp
Check if a Buffer/Uint8Array is a BMP image
Used by image-type.
Install
$ npm install --save is-bmp
$ bower install --save is-bmp
$ component install sindresorhus/is-bmp
Usage
Node.js
var readChunk = require('read-chunk');
var isBmp = require('is-bmp');
var buffer = readChunk.sync('unicorn.bmp', 0, 2);
isBmp(buffer);
Browser
var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.bmp');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
isBmp(new Uint8Array(this.response));
};
xhr.send();
API
isBmp(buffer)
Accepts a Buffer (Node.js) or Uint8Array.
It only needs the first 2 bytes.
License
MIT © Sindre Sorhus