png2bin
v0.2.3
Published
Decode data that has been encoded with bin2png
Downloads
8
Maintainers
Readme
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
Name | Type | Description
-------|--------|-------------
img | HTMLImageElement
| An image that has been encoded with png2bin