is-png

3.0.1last stable release 4 years ago
Complexity Score
Low
Open Issues
0
Dependent Projects
93
Weekly Downloadsglobal
718,169

License

  • MIT
    • Yesattribution
    • Permissivelinking
    • Permissivedistribution
    • Permissivemodification
    • Nopatent grant
    • Yesprivate use
    • Permissivesublicensing
    • Notrademark grant

Downloads

Readme

is-png

Check if a Buffer/Uint8Array is a PNG image

Install

$ npm install is-png

Usage

Node.js
import {readChunk} from 'read-chunk';
import isPng from 'is-png';

const buffer = await readChunk('unicorn.png', {length: 8});

isPng(buffer);
//=> true
Browser
import isPng from 'is-png';

const response = await fetch('unicorn.png');
const buffer = await response.arrayBuffer();

isPng(new Uint8Array(buffer));
//=> true

API

isPng(buffer)

Accepts a Buffer (Node.js) or Uint8Array. Returns a boolean of whether buffer is a PNG image.

buffer

The buffer to check. It only needs the first 8 bytes.

Related

  • file-type - Detect the file type of a Buffer/Uint8Array/ArrayBuffer

Dependencies

Loading dependencies...

CVE IssuesActive
0
Scorecards Score
4.20
Test Coverage
No Data
Follows Semver
Yes
Github Stars
47
Dependenciestotal
5
DependenciesOutdated
4
DependenciesDeprecated
0
Threat Modelling
No
Repo Audits
No

Learn how to distribute is-png in your own private NPM registry

npm config set registry  https://npm.cloudsmith.com/owner/repo
Processing...
Done
npm install is-png
Processing...
Done

7 Releases

NPM on Cloudsmith

Getting started with NPM on Cloudsmith is fast and easy.