meta-png
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

meta-png

NPM version codecov Test Lint

Simple, zero-dependencies NodeJS/JavaScript library to store and retrieve metadata in PNG files.

Installation

Use your favourite package manager

npm install meta-png
# or: yarn add meta-png

Usage

The library provides two functions to add a new metadata:

addMetadata(PNGUint8Array, key, value)  // stores the given key-value inside the PNG, provided as Uint8Array
addMetadataFromBase64DataURI(dataURI, key, value)  // stores the given key-value inside the PNG, provided as a Data URL string

and a function to get back the stored value:

getMetadata(PNGUint8Array, key)  // retrives the given key from a PNG provided as Uint8Array

Limitations

  • tEXt chunks inside PNG files are meant to use the Latin-1 standard: using characters outside this charset may lead to unwanted behaviors
  • No check is performed inside add functions to test whether a given key is already present in the file. If you need it, you can call getMetadata beforehand and assert that it gives back undefined.

Readme

Keywords

Package Sidebar

Install

npm i meta-png

Weekly Downloads

52,130

Version

1.0.6

License

ISC

Unpacked Size

6.45 kB

Total Files

4

Last publish

Collaborators

  • lucach