npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

img2braille

v1.0.1

Published

Dynamically converts an image to braille (ASCII) art

Downloads

140

Readme

npm NPM

Img2Braille - Dank Edition

JavaScript utility to generate braille (unicode) text from an image.

Installation

You may install this package with npm using:

npm install img2braille

Usage

After importing the package into your project, a braillefy method will be accessible to you. This function accepts 3 arguments, as described below:

  • imageURL (string) - The source URL of the target image. This can be represented as either a local or remote path.
  • asciiWidth (integer) - The desired width of the generated ASCII.
  • options - An object with following (all optional):
    • dither (boolean) - If truthy, a dithering effect will be applied to the output which will produce an overall cleaner/smoother result.
    • invert (boolean) - If truthy, the background colors will be inverted (light -> dark). This is especially useful in cases where you'd like to match a certain background color scheme.
    • lineSeparator (string) - Character of which to succeed each end-of-line. Default: \n (newline).
    • colors - An object representing RGB threshold levels to be applied during generation. Minimum: 0.01 - Maximum: 10. Default: { red: 1, green: 1, blue: 1 }.

Examples

const { braillefy } = require('img2braille');

(async () => {
    const asciiOpts = {
        dither: false,
        invert: false,
    };

    const result = await braillefy('https://i.nuuls.com/LAOzc.png', 30, asciiOpts);

    console.log(result);

    /*
    ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣿⣿⣿⣿⣷⡿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣫⣵⣿⣿⣿⣿⣿⣿⣿⣷⡻⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣿⡿⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣳⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⠍⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠄⠄⠄⠄⠄⠄⠙⢿⣿
    ⣿⣿⡿⠉⠄⠄⠄⠄⢤⣶⣾⣿⣿⠿⠷⠲⢶⣦⡄⠄⠄⠄⢀⣀⣀⣤⣤⣤⣤⣹
    ⣿⡿⠁⠄⠄⠄⠄⠄⠄⠉⠛⠻⠇⠈⠁⠄⠄⡿⣿⣿⣿⣿⣿⣿⠋⠄⠄⡀⢿⢿
    ⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠉⠛⠛⠃⠄⠄⠄⠄⣴⣾
    ⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠠⠄⠄⠄⣀⣹⣿
    ⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣴⣶⣿⣿⣿⣿
    ⣿⣆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣴⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣶⣤⣀⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣷⣶⣶⣤⣤⣤⣤⣤⣤⣤⣤⣴⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    */

    /* Dithering (dither: true):
    ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢯⣫⢯⢾⢽⢵⡻⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣯⡳⡯⣞⡽⡽⡽⡵⣯⣳⢽⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣿⡿⣫⣞⡽⣝⡮⡯⣯⣫⢯⣞⢮⢷⡹⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⡿⡽⡵⣳⢽⡳⡽⣽⡺⡮⡷⡽⡽⡽⣝⣞⢿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣫⢯⢯⣳⢯⢯⣻⣺⡺⡽⡽⣝⡽⣺⢵⣫⢞⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣳⣳⣫⢗⣯⡳⡯⣞⡮⡯⡯⣯⣺⢽⣺⢽⣺⣝⡮⢿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣗⣗⣗⡽⣝⡮⡯⣻⢮⢯⣫⢯⢞⡮⡷⣝⣗⣗⣗⡽⣝⢿⣿⣿⣿
    ⣿⣿⣿⣿⣿⢕⢕⢕⢝⢕⢝⢍⢇⢏⢝⢬⢭⠱⡍⡎⡎⡦⡱⡔⣜⢔⡕⡭⣻⣿
    ⣿⣿⡿⡹⡢⡣⣣⢣⢳⣵⣿⣿⡿⠟⠞⠞⢾⣮⡎⡇⢏⢎⢎⣎⣎⡦⡧⣧⣲⣹
    ⣿⡿⡱⡱⡕⣝⢜⡜⣕⢭⢛⡻⢅⠈⡁⠠⠄⡿⢯⣿⣿⣿⣿⡿⠋⠐⠄⡀⢿⢯
    ⣿⢇⢗⢕⡝⣜⢜⢼⢸⢜⢜⢜⢕⢕⢪⢪⠪⡪⡪⣪⢪⢫⢫⢣⢤⢰⢰⢰⣱⣿
    ⣿⢱⢕⢇⢧⢣⢳⡱⡣⡳⡱⡕⡕⡕⡕⡕⡕⡕⡝⡸⡨⢕⠕⠕⢅⢇⢕⢥⣹⣿
    ⣿⢸⢜⢎⢎⢧⢣⢇⢏⢮⢪⠸⡨⢌⢌⢌⢈⢄⢡⠠⢄⡢⡢⡱⣵⣶⣿⣿⣿⣿
    ⣿⡮⡪⢎⢧⢳⢱⢣⢳⢱⢣⢫⢪⢪⢢⢣⢣⢣⢣⢫⢕⢪⣺⣾⣿⣿⣿⣿⣿⣿
    ⢯⡻⡮⣮⣪⢪⢪⢕⢭⢪⢣⢫⢪⢕⢭⢪⢕⢕⢕⣕⡵⣻⣺⣺⣻⣿⣿⣿⣿⣿
    ⡯⣯⣻⣺⣺⣳⣳⢵⢵⢵⣹⣜⢵⢵⢵⢵⢵⡳⣯⣺⢽⢵⣳⣳⣳⣻⣿⣿⣿⣿
    ⡯⣞⣞⣞⣞⣞⢾⢽⢽⢽⣺⣺⢽⢽⢽⢽⢽⢽⣺⣺⢽⢽⣺⣺⣺⣺⣿⣿⣿⣿
    */

    /* Inverted with dithering (invert: true):
    ⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡐⠔⡐⡁⡂⡊⢄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
    ⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⠐⢌⢐⠡⢂⢂⢂⢊⠐⠌⡂⠄⠄⠄⠄⠄⠄⠄⠄⠄
    ⠄⠄⠄⠄⠄⠄⠄⠄⢀⠔⠡⢂⠢⢑⢐⠐⠔⡐⠡⡑⡈⢆⠄⠄⠄⠄⠄⠄⠄⠄
    ⠄⠄⠄⠄⠄⠄⠄⢀⢂⢊⠌⡂⢌⢂⠂⢅⢑⢈⢂⢂⢂⠢⠡⡀⠄⠄⠄⠄⠄⠄
    ⠄⠄⠄⠄⠄⠄⠄⠔⡐⡐⠌⡐⡐⠄⠅⢅⢂⢂⠢⢂⠅⡊⠔⡡⠄⠄⠄⠄⠄⠄
    ⠄⠄⠄⠄⠄⠄⠌⠌⠔⡨⠐⢌⢐⠡⢑⢐⢐⠐⠅⡂⠅⡂⠅⠢⢑⡀⠄⠄⠄⠄
    ⠄⠄⠄⠄⠄⠨⠨⠨⢂⠢⢑⢐⠄⡑⡐⠔⡐⡡⢑⢈⠢⠨⠨⠨⢂⠢⡀⠄⠄⠄
    ⠄⠄⠄⠄⠄⡪⡪⡪⡢⡪⡢⡲⡸⡰⡢⡓⡒⣎⢲⢱⢱⢙⢎⢫⠣⡫⢪⢒⠄⠄
    ⠄⠄⢀⢆⢝⢜⠜⡜⡌⠊⠄⠄⢀⣠⣡⣡⡁⠑⢱⢸⡰⡱⡱⠱⠱⢙⢘⠘⠍⠆
    ⠄⢀⢎⢎⢪⠢⡣⢣⠪⡒⡤⢄⡺⣷⢾⣟⣿⢀⡐⠄⠄⠄⠄⢀⣴⣯⣿⢿⡀⡐
    ⠄⡸⡨⡪⢢⠣⡣⡃⡇⡣⡣⡣⡪⡪⡕⡕⣕⢕⢕⠕⡕⡔⡔⡜⡛⡏⡏⡏⠎⠄
    ⠄⡎⡪⡸⡘⡜⡌⢎⢜⢌⢎⢪⢪⢪⢪⢪⢪⢪⢢⢇⢗⡪⣪⣪⡺⡸⡪⡚⠆⠄
    ⠄⡇⡣⡱⡱⡘⡜⡸⡰⡑⡕⣇⢗⡳⡳⡳⡷⡻⡞⣟⡻⢝⢝⢎⠊⠉⠄⠄⠄⠄
    ⠄⢑⢕⡱⡘⡌⡎⡜⡌⡎⡜⡔⡕⡕⡝⡜⡜⡜⡜⡔⡪⡕⠅⠁⠄⠄⠄⠄⠄⠄
    ⡐⢄⢑⠑⠕⡕⡕⡪⡒⡕⡜⡔⡕⡪⡒⡕⡪⡪⡪⠪⢊⠄⠅⠅⠄⠄⠄⠄⠄⠄
    ⢐⠐⠄⠅⠅⠌⠌⡊⡊⡊⠆⠣⡊⡊⡊⡊⡊⢌⠐⠅⡂⡊⠌⠌⠌⠄⠄⠄⠄⠄
    ⢐⠡⠡⠡⠡⠡⡁⡂⡂⡂⠅⠅⡂⡂⡂⡂⡂⡂⠅⠅⡂⡂⠅⠅⠅⠅⠄⠄⠄⠄
    */
})();

See the examples folder provided in the repo for more information.

Originally masterminded by the creator of https://505e06b2.github.io/Image-to-Braille, this utility has been refactored and converted into a node.js package.