data-to-png
v0.0.2
Published
A Javascript utility that lets you encode any data to png.
Downloads
3
Readme
data-to-png
A Javascript utility that lets you encode any data to png.
Install
yarn add data-to-png
Usage
import { encode } from 'data-to-png';
encode('Hello World!').then((png) => {
// Do something awesome with your png!
});
Example
Send jquery as a png from an express app to the browser.
const fs = require('fs');
const express = require('express');
const { encode } = require('data-to-png');
const app = express();
app.get('/test', function (req, res) {
fs.readFile('./jquery-3.1.1.min.js', 'utf8', (error, data) => {
encode(data).then((png) => {
res.writeHead(200, {
'Content-Type': 'image/png',
'Content-Length': png.length,
});
res.end(png);
})
});
});
app.listen(8080, function () {
console.log('Server listening on port 8080!');
});
The server will respond with the following png:
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request