node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »

is-psd

is-psd Build Status

Check if a Buffer/Uint8Array is a PSD image

Used by image-type.

Install

$ npm install --save is-psd

Usage

Node.js
var readChunk = require('read-chunk'); // npm install read-chunk 
var isPsd = require('is-psd');
var buffer = readChunk.sync('unicorn.psd', 0, 4);
 
isPsd(buffer);
//=> true 
Browser
var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.psd');
xhr.responseType = 'arraybuffer';
 
xhr.onload = function () {
    isPsd(new Uint8Array(this.response));
    //=> true 
};
 
xhr.send();

API

isPsd(buffer)

Accepts a Buffer (Node.js) or Uint8Array.

It only needs the first 4 bytes.

License

MIT © Sindre Sorhus