Skip to content

🎨 JavaScript utility to generate a braille text from an image

Notifications You must be signed in to change notification settings

mohayonao/seurat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

seurat

Build Status NPM Version Dependency Status License

JavaScript utility to generate a braille text from an image

Installation

Requirements

NPM

$ npm install -g seurat

Usage

$ seurat image/lena.jpg

⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣛⣃⡁⠀⠀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⣠⠄⠉
⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠜⡻⢿⣿⣿⣿⣿⣿⡟⠛⠛⠛⠛⢻⣿⣿⠓⠏⠈⠋⡆⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⣰⠟⠁⠀⠀
⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⣠⣾⢣⣿⡟⢻⣀⣤⣠⣤⣤⣈⡛⠋⠉⣧⡄⠄⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠘⠁⠀⠀⠀⠀
⣿⣿⠏⢹⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠁⣫⠴⠞⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠁⠀⠀⠀⠀⠀⣹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠂⠀⠀⠀⠀⠀⠀
⣿⠋⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠁⠀⠀⠈⠟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀⠀⠀⠀⢿⣿⣿⡏⠙⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⣠
⠁⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠀⠀⠀⣠⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⢸⣿⣿⡇⠀⠈⢿⣿⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⢠⣾⣿
⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⢀⡞⠀⠀⠀⠀⣨⣿⣿⡿⢋⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⢸⣿⣿⡇⠀⠀⢈⣽⣿⣟⠁⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⣸⡇⠀⠀⠀⠘⡡⠾⢉⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣼⣿⣿⣇⣠⣶⣿⣿⣿⣿⠀⠀⠀⠀⠀⢠⣾⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⣿⣆⠀⠀⠀⠀⢠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀⣠⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⣿⣿⣧⠀⢠⣾⠟⣡⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⠁⠀⠀⠀⣰⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢼⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⣿⣿⢻⡂⠙⣡⡾⢫⡼⣿⢟⠕⠀⠀⠻⠊⠉⠉⠉⢁⣽⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⣁⡼⠃⠀⠀⠀⣰⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⢃⡼⢋⠐⣩⠞⠃⠉⠀⠀⠀⠀⠀⠀⢠⣴⣿⣿⣿⣿⣿⣿⠟⠋⠉⣶⣶⡿⠋⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⣿⡿⠀⠐⣩⠔⠀⠀⠀⠀⠀⠀⠀⠀⠀⣨⣾⣿⣿⣿⣿⣿⣿⣿⣷⠀⠈⣾⠉⠀⠀⠀⠀⠀⢀⣧⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠂⠀⠸⠇⣠⡼⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⠀⢸⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⡀⠀⠀⠀⠀⠀⠀⣰⡃⠹⠎⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⢿⠭⡉⠛⢿⣿⣿⣿⡿⠟⠃⠀⠈⡇⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⠃⠀⠀⠀⠀⠰⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⢋⠀⠀⢀⣦⠈⠚⣿⣿⠏⠀⣤⠀⠀⠀⡇⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⡇⠀⠀⠠⡴⠋⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⠏⢱⣿⣷⣦⣭⣿⣿⣴⢻⣿⣿⣯⡁⠀⠀⠀⣧⠀⠀⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⡇⠀⠀⡉⠁⠀⠀⢀⠀⠀⠀⠀⠀⠢⠀⠀⣰⡟⠁⠀⢸⣿⣿⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿⠀⠀⠀⢿⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⡇⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠊⠁⢠⣴⠏⠀⠀⠀⢸⣿⣿⣿⣿⣿⡏⡷⠜⣿⣿⣿⡏⠀⠀⠀⢸⡄⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⡇⠀⢠⠀⠀⠀⠀⠀⠱⠀⠀⠀⣠⡔⡸⠃⠀⠀⠀⠀⢈⣿⣿⣿⣿⣿⣿⣶⣶⣾⣿⡿⠁⠀⠀⠀⠘⡇⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⣇⠀⡠⠀⠀⠀⢀⠀⠀⠈⣠⣷⢏⠔⠀⠀⠀⠀⠀⠀⠸⠻⣿⣿⣉⠛⣛⣋⣻⣉⡹⠁⠀⠀⠀⠀⠀⣧⣿⣿⣿⣿⣿⣿⣿⣧⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⡇⠐⠁⠀⠀⠀⠨⢠⠀⠂⠋⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣷⣬⣭⣽⡟⠁⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⠉⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⢸⣿⣿⣿⢇⡠⠀⠀⠀⠀⢠⠀⠁⠊⡆⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣉⣛⣿⣿⣿⣿⣁⠀⠀⠀⠀⠀⠀⠀⣿⠛⠿⠿⣿⣿⣿⡿⢸⣿⣿⣿⣿⡿⠟⠋
⣤⡀⠀⠈⣿⣿⣿⣏⠄⠀⠀⠀⠀⠀⠀⠘⠀⢀⡘⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⢜⣿⣿⣿⣿⣿⣿⣿⣶⣤⡀⠀⠀⠀⣿⣶⣦⣤⣀⠀⠀⡀⢸⣿⣿⡿⠋⠀⠀⠀
⠘⣿⡆⠀⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⡌⢠⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⢀⣿⣿⣿⣿⣿⣧⠄⣧⣿⣿⡿⠁⠀⠀⠀⠀
⠀⢻⡇⠀⣿⣿⣿⡟⠀⠀⠀⠀⠂⠀⠀⠀⠀⠀⣸⠇⡜⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⢸⣿⣿⣿⣿⣿⠃⣾⣿⣿⣿⠃⠀⠀⠀⠀⠀
⠀⢸⣿⠀⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠢⡀⠀⠀⠀⠀⠀⠘⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡸⠿⢿⣿⣿⣿⣶⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀
⠀⢸⣿⠀⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢢⡀⠀⠀⠀⠀⠀⠀⠀⠁⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀⠈⠙⣻⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠸⣿⡆⣿⣿⣿⡅⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⠀⠀⠀⠀⢽⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣿⡧⣻⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣽⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⡀⢀⡀⠀⠀⠀⠀⢀⠀⠀⠀⠀

* The braille characters cannot display on Windows.

Options

$ seurat --help

Usage: seurat [options] path/to/image

  -w, --width Number      width(cols) of the converted text
  -h, --height Number     height(rows) of the converted text
  -t, --threshold Number  threshold for binarization
  -i, --invert            invert to negative
  -o, --output String     write the converted text to this file
  -p, --print             print out the converted text
  -v, --version           show version
  --help                  show help

API

  • convert(src: string|Buffer, opts: object): Promise<string>
    • src: string path of the source image file
    • src: Buffer Buffer of the source image
    • opts: object
      • width: number width(cols) of the converted text - default: 60
      • height: number height(rows) of the converted text
      • threshold: number threshold for binarization - default: 50(%)
      • invert: boolean invert to negative

Example

var seurat = require("seurat");

seurat.convert("image/lena.jpg", {
  width: 100, height: 50, threshold: 25
}).then(function(result) {
  conosle.log(result);
});

License

MIT

About

🎨 JavaScript utility to generate a braille text from an image

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published