Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-png

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-png

Check if a Buffer/Uint8Array is a PNG image

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
706K
increased by1.04%
Maintainers
1
Weekly downloads
 
Created

What is is-png?

The is-png npm package is a utility that allows you to check if a given buffer or file is a PNG image. It is useful for validating image formats in various applications.

What are is-png's main functionalities?

Check if a buffer is a PNG

This feature allows you to check if a given buffer contains a PNG image. You can read a file into a buffer and then use the isPng function to validate its format.

const isPng = require('is-png');
const fs = require('fs');

const buffer = fs.readFileSync('path/to/image.png');
console.log(isPng(buffer)); // true if the buffer is a PNG, false otherwise

Check if a file is a PNG

This feature allows you to check if a given file is a PNG image by reading the file asynchronously and then using the isPng function to validate its format.

const isPng = require('is-png');
const fs = require('fs');

fs.readFile('path/to/image.png', (err, data) => {
  if (err) throw err;
  console.log(isPng(data)); // true if the file is a PNG, false otherwise
});

Other packages similar to is-png

Keywords

FAQs

Package last updated on 02 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc