1.0.3 • Published 3 years ago

@vereign/lib-png v1.0.3

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
-
Last release
3 years ago

Lib PNG

Table of contents

[TOC]

JavaScript PNG encoder/decoder with metadata storage functionality

Installation

  • Set up authentication to the company NPM account
  • $ yarn add @vereign/lib-png or $ npm install @vereign/lib-png

Usage

import PNG from "@vereign/png"

Initialization

Browser

function base64ToBytes(base64) {
    var binary_string = window.atob(base64);
    var len = binary_string.length;
    var bytes = new Uint8Array(len);
    for (var i = 0; i < len; i++) {
        bytes[i] = binary_string.charCodeAt(i);
    }
    return bytes;
}

const pngBase64 = "iVBORw0KGgoAA...JRU5ErkJggg==";
const png = PNG.readPng(base64ToBytes(pngBase64));

Node.JS

const pngBase64 = "iVBORw0KGgoAA...JRU5ErkJggg==";
const png = PNG.readPng(Buffer.from(pngBase64, "base64"));

Google Script

const pngBase64 = "iVBORw0KGgoAA...JRU5ErkJggg==";
const png = PNG.readPng(new Uint8Array(Utilities.base64Decode(pngBase64)));

Metadata API

import { addMetaData, getMetaData } from "@veriegn/png"

const pngBase64 = "iVBORw0KGgoAA...JRU5ErkJggg==";
const png = PNG.readPng(Buffer.from(pngBase64, "base64"));

addMetaData(png, "abra", "cadabra");
addMetaData(png, "hello", "merlo");
const metaData = getMetaData(png);

Changelog

CHANGELOG.md

License

AGPLv3

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago