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

png-validator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

png-validator

Png validator checks Png files for corruption

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
decreased by-14.29%
Maintainers
1
Weekly downloads
 
Created
Source

Png Validator

Checks Png files for corruption.

This code is cut out of the much more comprehensive https://github.com/lukeapage/pngjs, so you can have a minimal implementation that only does png file validation.

It checks that the chunk layout is correct, and it checks that the crc code for each chunk is valid.

Zero dependencies and only 2.6 kb after minification.

Available as an npm package: https://www.npmjs.com/package/png-validator

Usage

There is only a single function exposed called pngValidator that takes a single parameter, which is an Uint8Array with the raw Png file data. It will throw an error if the file is not valid.

import { pngValidator } from 'png-validator';

try {
	pngValidator(buffer);
	// success
} catch (e) {
	// file is invalid or corrupt
	console.error(e);
}

From version 2.0 on there is only an esm version of Png Validator. Use v. 1.1 if you need commonjs.

Keywords

FAQs

Package last updated on 16 Nov 2023

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