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