1 # is-jpg [![Build Status](https://travis-ci.org/sindresorhus/is-jpg.svg?branch=master)](https://travis-ci.org/sindresorhus/is-jpg)
3 > Check if a Buffer/Uint8Array is a [JPEG](http://en.wikipedia.org/wiki/JPEG) image
5 Used by [image-type](https://github.com/sindresorhus/image-type).
11 $ npm install --save is-jpg
20 var readChunk = require('read-chunk'); // npm install read-chunk
21 var isJpg = require('is-jpg');
22 var buffer = readChunk.sync('unicorn.jpg', 0, 3);
31 var xhr = new XMLHttpRequest();
32 xhr.open('GET', 'unicorn.jpg');
33 xhr.responseType = 'arraybuffer';
35 xhr.onload = function () {
36 isJpg(new Uint8Array(this.response));
48 Accepts a Buffer (Node.js) or Uint8Array.
50 It only needs the first 3 bytes.
55 MIT © [Sindre Sorhus](http://sindresorhus.com)