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

is-psd

Check if a Buffer/Uint8Array is a PSD image

Install

$ npm install is-psd

Usage

Node.js
import {readChunkSync} from 'read-chunk';
import isPsd from 'is-psd';

const buffer = readChunkSync('unicorn.psd', {length: 4});

isPsd(buffer);
//=> true
Browser
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.psd');
xhr.responseType = 'arraybuffer';

xhr.onload = () => {
	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.

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                                ...           9 years ago
  • 1.0.0                                ...           12 years ago
  • 0.1.1                                ...           13 years ago
  • 0.1.0                                ...           13 years ago
Maintainers (1)
Downloads
Total 12
Today 0
This Week 0
This Month 7
Last Day 0
Last Week 6
Last Month 0
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE