@cjser/is-psd
v2.0.0-cjser.2
Published
Check if a Buffer/Uint8Array is a PSD image
Maintainers
Readme
is-psd
Check if a Buffer/Uint8Array is a PSD image
Install
$ npm install is-psdUsage
Node.js
import {readChunkSync} from 'read-chunk';
import isPsd from 'is-psd';
const buffer = readChunkSync('unicorn.psd', {length: 4});
isPsd(buffer);
//=> trueBrowser
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
cjser
This package is a CommonJS-compatible build generated by cjser for projects that still need require() support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
Original repository: https://github.com/sindresorhus/is-psd
