$ npm install is-png
Check if a Buffer/Uint8Array is a PNG image
$ npm install is-png
import {readChunk} from 'read-chunk';
import isPng from 'is-png';
const buffer = await readChunk('unicorn.png', {length: 8});
isPng(buffer);
//=> true
import isPng from 'is-png';
const response = await fetch('unicorn.png');
const buffer = await response.arrayBuffer();
isPng(new Uint8Array(buffer));
//=> true
Accepts a Buffer (Node.js) or Uint8Array. Returns a boolean
of whether buffer
is a PNG image.
The buffer to check. It only needs the first 8 bytes.
© 2010 - cnpmjs.org x YWFE | Home | YWFE