Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

img2braille-web

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

img2braille-web

Dynamically converts an image to braille (ASCII) art

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm NPM

Img2Braille-web

Forked from https://github.com/5E7EN/Img2Braille and modified to work in a web browser.

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

Installation

You may install this package with npm using:

npm install img2braille-web

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 - smoothing edges and producing an overall cleaner 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-web');

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

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

    console.log(result);

    /*
    ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣿⠟⠋⠉⠉⠉⠉⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⡿⠋⠄⣠⣤⡀⠄⠄⠄⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⡏⠄⠉⠛⠄⠄⠰⠁⠜⠄⠄⠄⠄⠐⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣇⠄⠢⠄⠠⣀⠄⠄⠄⠄⠄⠄⠄⠄⣾⠃⢿⣿⣿⣿⣿⣿⣿⠿⠿⢿⣿⣿
    ⣿⣿⣿⠆⠄⠄⠄⠈⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⠿⠋⠁⠄⠄⠄⣿⣿
    ⣿⣿⣷⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣾⠿⠋⠁⠄⠄⢀⠄⠄⠄⣿⣿
    ⣿⣿⣿⣿⡿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠐⠒⠄⠄⢈⡆⠄⠄⣿⣿
    ⣿⣿⡟⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⠄⠄⢿⣿
    ⣿⣿⠃⣀⣀⣄⠄⠄⠄⠄⠄⢀⣠⣀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⠄⠄⣼⣿
    ⣿⡯⠸⣿⠏⠄⠄⠄⠄⠄⠄⠘⢿⠿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣿⣿
    ⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣠⣿⣿
    ⣿⣿⣄⠄⠄⠄⠄⢀⣀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣀⣴⣿⣿⣿
    ⣿⣿⣿⣷⣦⣤⣀⣈⡛⠓⠄⠄⠄⠄⠄⢀⣀⣀⣀⣠⣤⣤⣶⣾⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    */

    /* Dithering (dither: true):
    ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣿⡿⡫⣏⢗⢽⢝⣟⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⡫⡎⣏⣮⡣⡳⡱⡳⣝⣞⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⢏⠢⡉⠫⢃⠳⡹⠁⢜⢜⢜⢮⢹⡪⣗⡷⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⣿⣿⣇⠑⠌⡂⠡⣈⢊⢎⢎⢎⢎⡎⡧⣻⡺⡽⣽⣿⣿⣿⣿⣿⣿⡿⡿⣿⣿⣿
    ⣿⣿⣿⠊⠄⠂⡁⠈⢃⠪⡸⡸⡱⡱⡝⣎⢯⡫⣾⣿⣿⣿⢿⢫⢣⢣⢫⡪⣿⣿
    ⣿⣿⣷⣥⠁⡁⠠⢈⠄⢕⠱⡨⡊⢎⢎⢎⢇⢏⣾⢿⡫⡫⡪⡪⣪⢪⢢⡫⣞⣿
    ⣿⣿⣿⣿⡿⡢⣕⡐⡅⠕⡑⡐⢌⠢⣑⢰⢡⢳⢱⢣⢳⢳⢕⣝⢮⣇⢧⡫⣞⣿
    ⣿⣿⣟⢗⢽⡹⣔⢕⡕⣕⢕⢎⢮⡪⣎⢮⡪⣎⢮⢮⢪⡳⡕⣗⣝⢮⣗⢽⣳⣿
    ⣿⣟⡮⣯⣳⢽⡪⡧⡫⣎⢮⢳⣱⣕⢵⢱⢕⢕⢕⢕⢵⢱⢝⣜⢮⣳⣝⣗⡷⣿
    ⣿⣳⣝⣿⢯⡳⣝⢎⢧⢣⢣⢝⢾⢺⢸⢸⢸⢸⢸⢸⢪⢣⡳⣕⢝⢮⣺⡪⣿⣿
    ⣿⣗⣕⢗⡳⡝⡜⡎⡮⡪⡪⡢⡣⡱⡑⡅⡇⡕⢕⢕⢕⢵⢱⢕⢝⢵⢕⣽⣿⣿
    ⣿⣷⣗⢵⢹⢸⢱⢱⣱⢱⠱⡱⡘⡌⡎⡪⡢⡣⡣⡱⡱⡑⡕⡕⡝⣜⣼⣿⣿⣿
    ⣿⣿⣿⣷⣧⣧⣃⣣⡋⠇⠇⠣⠃⠇⠣⣃⣣⣑⣘⣨⣦⣵⣷⣾⣿⣿⣿⣿⣿⣿
    ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    */

    /* Inverted with dithering (invert: true):
    ⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
    ⠄⠄⠄⠄⠄⠄⠄⠄⢀⢔⠰⡨⡂⡢⠠⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
    ⠄⠄⠄⠄⠄⠄⠄⢔⢱⠰⠑⢜⢌⢎⢌⠢⠡⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
    ⠄⠄⡰⣝⢶⣔⡼⣌⢆⣾⡣⡣⡣⡑⡆⢕⠨⢈⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
    ⠄⠄⠸⣮⣳⢽⣞⠷⡵⡱⡱⡱⡱⢱⢘⠄⢅⢂⠂⠄⠄⠄⠄⠄⠄⢀⢀⠄⠄⠄
    ⠄⠄⠄⣵⣻⣽⢾⣷⡼⣕⢇⢇⢎⢎⢢⠱⡐⢔⠁⠄⠄⠄⡀⡔⡜⡜⡔⢕⠄⠄
    ⠄⠄⠈⠚⣾⢾⣟⡷⣻⡪⣎⢗⢵⡱⡱⡱⡸⡰⠁⡀⢔⢔⢕⢕⠕⡕⡝⢔⠡⠄
    ⠄⠄⠄⠄⢀⢝⠪⢯⢺⣪⢮⢯⡳⣝⠮⡏⡞⡌⡎⡜⡌⡌⡪⠢⡑⠸⡘⢔⠡⠄
    ⠄⠄⠠⡨⡂⢆⠫⡪⢪⠪⡪⡱⡑⢕⠱⡑⢕⠱⡑⡑⡕⢌⢪⠨⠢⡑⠨⡂⠌⠄
    ⠄⠠⢑⠐⠌⡂⢕⢘⢔⠱⡑⡌⠎⠪⡊⡎⡪⡪⡪⡪⡊⡎⡢⠣⡑⠌⠢⠨⢈⠄
    ⠄⠌⠢⠄⡐⢌⠢⡱⡘⡜⡜⡢⡁⡅⡇⡇⡇⡇⡇⡇⡕⡜⢌⠪⡢⡑⠅⢕⠄⠄
    ⠄⠨⠪⡨⢌⢢⢣⢱⢑⢕⢕⢝⢜⢎⢮⢺⢸⢪⡪⡪⡪⡊⡎⡪⡢⡊⡪⠂⠄⠄
    ⠄⠈⠨⡊⡆⡇⡎⡎⠎⡎⣎⢎⢧⢳⢱⢕⢝⢜⢜⢎⢎⢮⢪⢪⢢⠣⠃⠄⠄⠄
    ⠄⠄⠄⠈⠘⠘⠼⠜⢴⣸⣸⣜⣼⣸⣜⠼⠜⠮⠧⠗⠙⠊⠈⠁⠄⠄⠄⠄⠄⠄
    ⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
    */
})();

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

API

API Base URL: https://api.5e7en.me

Please set a proper User-Agent HTTP header referencing your application along with your request when used as a long-term solution.

  • GET /generateASCII

    Query parameters:

    • url (string) - The source URL of the target image. This must be a remote path.
    • size (integer) - The desired width of the generated ASCII. Maximum size: 250.
    • dither (boolean) - If truthy, a dithering effect will be applied to the output - smoothing edges and producing an overall cleaner result. Default: false.
    • 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. Default: false.

For more information, see the full API docs.




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.

Keywords

FAQs

Package last updated on 18 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc