8000 GitHub - sindresorhus/is-psd: Check if a Buffer/Uint8Array is a PSD image
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sindresorhus/is-psd

Repository files navigation

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

About

Check if a Buffer/Uint8Array is a PSD image

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0