Skip to content

dqn/tenjify

Repository files navigation

tenjify

CI npm version

Convert the image to Braille.

Installation

Using yarn:

$ yarn add tenjify

Using npm:

$ npm install tenjify

Example

const { tenjify } = require("tenjify");

const text = await tenjify("./twitter.png", { width: 40, threshold: 150 });
console.log(text);

//⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣶⣶⣶⣦⣄⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⢠⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⠟⠁⡀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⠸⣿⣿⣿⣦⣄⡀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⣷⣦⣤⣀⣀⠀⠀⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⢠⣀⣙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣈⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠛⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⠈⠙⠻⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⣤⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡄⠀⣤⡀⠀⠀⠀⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
//⠀⣿⣧⣀⣀⣀⠀⣠⡀⠀⢀⣄⠀⠀⣠⠀⢀⣄⠀⣿⣇⣀⣀⠀⣿⣄⣀⡀⠀⢀⣠⣤⣀⠀⠀⠀⣀⣀⣀⠀
//⠀⣿⡏⠉⠉⠉⠀⣿⡇⠀⢸⣿⠀⠀⣿⡇⢸⣿⠀⣿⡏⠉⠁⠀⣿⡋⠉⠁⢰⣿⣥⣤⣽⡷⠀⣾⠋⠉⠉⠀
//⠀⠙⢿⣶⣶⣶⠀⠹⢷⣶⡾⠿⣶⣶⠟⠀⢸⡿⠀⠹⢷⣶⣶⠀⠻⢷⣶⡦⠈⠻⣦⣤⣤⡄⠀⣿⠀⠀⠀⠀

Options

name type required description default
width number optional width of the text to be generated 30
threshold number optional threshold for binarization (0-255) 128
reverse boolean optional reverse black and white false

License

MIT