png2bin

0.2.3 • Public • Published

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

Package Sidebar

Install

npm i png2bin

Weekly Downloads

6

Version

0.2.3

License

LGPL-3.0-or-later

Unpacked Size

3.93 kB

Total Files

4

Last publish

Collaborators

  • lovasoa