0.2.3 • Published 3 years ago

png2bin v0.2.3

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

png2bin

For more information, please look at the project page.

Usage

You first need to encode a file with bin2png. Then, you can inline it as a base64 data URL, in an HTML file like this:

<img id="myfile"
    decoding="async" loading="eager"
    style="display:none"
    src="data:image/png;base64,..." />

In your code, you can then decode the image and get back the original file data:

import { png2bin } from "png2bin";

var img = document.getElementById("myfile");
var mydata = await png2bin(img);
// mydata is an Uint8Array with the contents of the original file

API

(async) png2bin(img) → {Uint8Array}

Decodes an image encoded with png2bin and returns the decoded file as an Uint8Array

Parameters

NameTypeDescription
imgHTMLImageElementAn image that has been encoded with png2bin
0.2.3

3 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.0

4 years ago