Turn images into braille text.
npm install brailleify --save
function brailleify(image, options = {})
image
is a browser canvas context object, or a Jimp image bitmap.options
is an object with the following options:align: Boolean
uses a non-space braille character to keep the image aligned vertically. Default istrue
.invert: Boolean
switches the mapping of braille characters so darker regions are mapped to fewer dots, and vice versa. Default isfalse
.threshold: Integer
affects the overall "shade" of the braille, ranging from 0-255. Default is120
.scale: Integer
determines the scale of the image pixels to the braille dots. 1 means 1 pixel per dot, 2 means 4 pixels per dot, and so on. Default is4
.
var Jimp = require('jimp');
var brailleify = require('brailleify');
Jimp.read('./joy.png')
.then(image => brailleify(image.bitmap, {threshold: 122, scale: 2}))
.then(console.log);
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠿⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠏⠃⠁⢀⢀⢀⢀⢀⢀⢀⢀⢀⠃⠋⠯⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⠟⠇⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⠃⠯⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⠟⠁⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⠂⠯⣿⣿⣿⣿⣿
⣿⣿⣿⣿⠇⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⠂⢿⣿⣿⣿
⣿⣿⡿⠁⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢯⣿⣿
⣿⣿⠅⢀⢀⢀⢀⢀⣠⣰⡰⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢰⣰⣐⡀⢀⢀⢀⢀⠂⣿⣿
⣿⡟⢀⢀⢀⢀⣠⡿⠇⠁⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⠋⢿⣴⢀⢀⢀⢀⣪⣿
⣿⡕⢀⢀⢀⣪⠗⢀⣠⣸⣼⣼⣼⣼⣰⡀⢀⢀⢀⢀⢀⣠⣸⣼⣼⣼⣼⣰⡀⠋⢵⢀⢀⢀⠃⣿
⣿⡕⢀⢀⢀⢀⢀⠊⠇⠃⠃⢀⠂⠃⠃⠇⢀⢀⢀⢀⠂⠇⠃⠃⢀⠂⠃⠋⠏⢀⢀⢀⢀⢀⢀⣿
⣿⣕⣕⡀⢀⢀⢀⡼⠴⣰⣐⣀⣀⡀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣀⣠⣰⠸⣼⢀⢀⢀⢀⢀⢯⣿
⡿⡯⠇⢀⢀⢀⢀⢭⢀⢀⢀⠃⠃⠃⠃⠏⠏⠏⠏⠏⠏⠃⠃⠃⠃⢀⢀⢀⡞⢀⢀⢀⢀⠉⢾⢿
⠃⢀⢀⢀⢀⢀⡀⠂⢽⣼⣰⣰⣀⣀⣀⣀⢀⢀⢀⢀⣀⣀⣀⣠⣰⣰⣼⡞⢀⢀⢀⢀⢀⢀⢀⠃
⣐⢀⢀⢀⢀⢀⢀⢀⢀⠋⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠇⢀⢀⢀⢀⢀⢀⢀⢀⢠
⣿⣽⣰⣰⣸⣘⢐⢀⢀⢀⢀⠋⠯⢿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠇⢀⢀⢀⢀⣠⢤⣴⣰⣰⣼⣿
⣿⣿⣿⣿⣿⣿⣽⣙⡰⡀⢀⢀⢀⢀⢀⠃⠃⠃⠃⠃⠃⢀⢀⢀⢀⢀⢀⡠⣦⣽⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣙⣤⠰⣀⡀⢀⢀⢀⢀⢀⢀⢀⣀⡠⢘⣤⣹⣾⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣼⣷⣳⣳⣳⣳⣳⣽⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿