bin2png

Convert binary data to a png in order to embed it efficiently.

Usage no npm install needed!

<script type="module">
  import bin2png from 'https://cdn.skypack.dev/bin2png';
</script>

README

bin2png

For more information, please look at the project page.

Usage

To convert a file at the path file.bin to a png that will be created at the path encoded.png:

npx bin2png file.bin encoded.png

Programmatic API

(async) bin2png(data) → {Promise.<Uint8Array>}

Takes binary data in the form of an UInt8Array and returns binary data representing a valid PNG file containing the original data. The data can then be decoded with png2bin.

Parameters

  • data Uint8Array The raw input data to encode.

(async) encode_file(binFileName, pngFileName) → {Promise.<Uint8Array>}

Encodes a file with bin2png and saves the result in another file.

Parameters

  • binFileName string A path to an existing file to encode
  • pngFileName string A path to a file that will be created with the contents