├── .babelrc ├── .gitignore ├── test ├── mocha.opts └── seurat.js ├── image └── lena.jpg ├── .travis.yml ├── src ├── cli.js ├── options.js └── seurat.js ├── package.json └── README.md /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "experimental": true 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE 2 | node_modules/ 3 | lib/ 4 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --reporter spec 2 | --compilers js:babel/register 3 | -------------------------------------------------------------------------------- /image/lena.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohayonao/seurat/HEAD/image/lena.jpg -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.12" 4 | before_install: 5 | - sudo apt-get update 6 | - sudo apt-get install graphicsmagick 7 | script: 8 | - npm run travis 9 | -------------------------------------------------------------------------------- /src/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | "use strict"; 4 | 5 | import fs from "fs"; 6 | import prominence from "prominence"; 7 | import * as seurat from "./seurat"; 8 | import * as options from "./options"; 9 | 10 | options.parse(process.argv, (args, opts) => { 11 | prominence(fs).readFile(args[0]).then((data) => { 12 | return seurat.convert(data, opts); 13 | }).then((result) => { 14 | if (!opts.print && opts.output) { 15 | return prominence(fs).writeFile(opts.output, result); 16 | } else { 17 | console.log(result); 18 | return result; 19 | } 20 | }).catch(console.error.bind(console)); 21 | }); 22 | -------------------------------------------------------------------------------- /test/seurat.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | import assert from "power-assert"; 4 | import * as seurat from "../src/seurat"; 5 | 6 | describe("seurat", () => { 7 | describe("convert(src: string|Buffer, opts: object): Promise", () => { 8 | it("works", () => { 9 | let filename = `${__dirname}/../image/lena.jpg`; 10 | return seurat.convert(filename, { 11 | width: 40, height: 30, threshold: 50 12 | }).then((result) => { 13 | console.log(result); 14 | assert(typeof result === "string"); 15 | assert(result.split("\n").length === 30); 16 | assert(result.split("\n")[0].length === 40); 17 | }, () => { 18 | throw new Error("NOT REACHED"); 19 | }); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "seurat", 3 | "description": "utility to generate a braille text from an image", 4 | "version": "0.0.4", 5 | "author": "mohayonao ", 6 | "bin": { 7 | "seurat": "./lib/cli.js" 8 | }, 9 | "bugs": { 10 | "url": "https://github.com/mohayonao/seurat/issues" 11 | }, 12 | "dependencies": { 13 | "babel": "^4.7.8", 14 | "gm": "^1.17.0", 15 | "optionator": "^0.5.0", 16 | "pngparse": "^2.0.1", 17 | "prominence": "^0.2.0" 18 | }, 19 | "devDependencies": { 20 | "espower-babel": "^1.3.0", 21 | "mocha": "^2.2.1", 22 | "power-assert": "^0.10.2" 23 | }, 24 | "files": [ 25 | "package.json", 26 | "README.md", 27 | "lib" 28 | ], 29 | "keywords": [], 30 | "licenses": "MIT", 31 | "main": "lib/seurat.js", 32 | "preferGlobal": true, 33 | "repository": { 34 | "type": "git", 35 | "url": "https://github.com/mohayonao/seurat.git" 36 | }, 37 | "scripts": { 38 | "build": "babel src --out-dir lib", 39 | "test": "mocha --require espower-babel/guess", 40 | "travis": "npm run test" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/options.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | import pkg from "../package"; 4 | import optionator from "optionator"; 5 | 6 | export let options = [ 7 | { 8 | option: "width", 9 | alias: "w", 10 | type: "Number", 11 | description: "width(cols) of the converted text" 12 | }, 13 | { 14 | option: "height", 15 | alias: "h", 16 | type: "Number", 17 | description: "height(rows) of the converted text" 18 | }, 19 | { 20 | option: "threshold", 21 | alias: "t", 22 | type: "Number", 23 | description: "threshold for binarization" 24 | }, 25 | { 26 | option: "invert", 27 | alias: "i", 28 | type: "Boolean", 29 | description: "invert to negative" 30 | }, 31 | { 32 | option: "output", 33 | alias: "o", 34 | type: "String", 35 | description: "write the converted text to this file" 36 | }, 37 | { 38 | option: "print", 39 | alias: "p", 40 | type: "Boolean", 41 | description: "print out the converted text" 42 | }, 43 | { 44 | option: "version", 45 | alias: "v", 46 | type: "Boolean", 47 | description: "show version" 48 | }, 49 | { 50 | option: "help", 51 | type: "Boolean", 52 | description: "show help" 53 | }, 54 | ]; 55 | 56 | export let parse = (argv, callback) => { 57 | let parser = optionator({ 58 | prepend: `Usage: ${pkg.name} [options] path/to/image`, 59 | options: options 60 | }); 61 | let opts = parser.parse(argv); 62 | 63 | if (opts.help || opts._.length === 0) { 64 | return console.log(parser.generateHelp()); 65 | } 66 | 67 | if (opts.version) { 68 | return console.log("v" + pkg.version); 69 | } 70 | 71 | callback(opts._, opts); 72 | }; 73 | 74 | export default parse; 75 | -------------------------------------------------------------------------------- /src/seurat.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | import "babel/polyfill"; 4 | 5 | import gm from "gm"; 6 | import pngparse from "pngparse"; 7 | import prominence from "prominence"; 8 | 9 | const DEFAULT_WIDTH = 60; 10 | const DEFAULT_THRESHOLD = 50; 11 | 12 | let brailleChars = "⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙⡚⡛⡜⡝⡞⡟⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿"; 13 | 14 | let createParams = (opts = {}, ratio = 1) => { 15 | let result = {}; 16 | 17 | if (typeof opts.width !== "number") { 18 | if (typeof opts.height !== "number") { 19 | result.width = DEFAULT_WIDTH; 20 | result.height = result.width * ratio * 0.5; 21 | } else { 22 | result.width = opts.height / ratio * 2; 23 | result.height = opts.height; 24 | } 25 | } else { 26 | if (typeof opts.height !== "number") { 27 | result.width = opts.width; 28 | result.height = result.width * ratio * 0.5; 29 | } else { 30 | result.width = opts.width; 31 | result.height = opts.height; 32 | } 33 | } 34 | 35 | if (typeof opts.threshold !== "number") { 36 | result.threshold = DEFAULT_THRESHOLD; 37 | } else { 38 | result.threshold = opts.threshold; 39 | } 40 | 41 | result.width = (result.width * 2)|0; 42 | result.height = (result.height * 4)|0; 43 | result.threshold = Math.max(0, Math.min(result.threshold|0, 100)); 44 | result.invert = !!opts.invert; 45 | 46 | return result; 47 | }; 48 | 49 | let brailleCodeAt = (png, x, y) => { 50 | let num = 0; 51 | 52 | num += png.getPixel(x + 0, y + 0) !== 255 ? 1 : 0; 53 | num += png.getPixel(x + 0, y + 1) !== 255 ? 2 : 0; 54 | num += png.getPixel(x + 0, y + 2) !== 255 ? 4 : 0; 55 | num += png.getPixel(x + 0, y + 3) !== 255 ? 8 : 0; 56 | num += png.getPixel(x + 1, y + 0) !== 255 ? 16 : 0; 57 | num += png.getPixel(x + 1, y + 1) !== 255 ? 32 : 0; 58 | num += png.getPixel(x + 1, y + 2) !== 255 ? 64 : 0; 59 | num += png.getPixel(x + 1, y + 3) !== 255 ? 128 : 0; 60 | 61 | return num; 62 | }; 63 | 64 | export async function convert(src, opts) { 65 | let im = gm(src); 66 | let size = await prominence(im).size(); 67 | let params = createParams(opts, size.height / size.width); 68 | 69 | im = im.resize(params.width, params.height, "!"); 70 | im = im.threshold(`${params.threshold}%`); 71 | 72 | if (params.invert) { 73 | im = im.negative(); 74 | } 75 | 76 | let buffer = await prominence(im).toBuffer("png"); 77 | let png = await prominence(pngparse).parse(buffer); 78 | 79 | let result = ""; 80 | 81 | for (let y = 0; y < png.height; y += 4) { 82 | for (let x = 0; x < png.width; x += 2) { 83 | result += brailleChars.charAt(brailleCodeAt(png, x, y)); 84 | } 85 | result += "\n"; 86 | } 87 | 88 | return result.trim(); 89 | }; 90 | 91 | export default convert; 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # seurat 2 | [![Build Status](http://img.shields.io/travis/mohayonao/seurat.svg?style=flat-square)](https://travis-ci.org/mohayonao/seurat) 3 | [![NPM Version](http://img.shields.io/npm/v/seurat.svg?style=flat-square)](https://www.npmjs.org/package/seurat) 4 | [![Dependency Status](http://img.shields.io/david/mohayonao/seurat.svg?style=flat-square)](https://david-dm.org/mohayonao/seurat) 5 | [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://mohayonao.mit-license.org/) 6 | 7 | > JavaScript utility to generate a braille text from an image 8 | 9 | ## Installation 10 | 11 | ### Requirements 12 | 13 | - [GraphicsMagick](http://www.graphicsmagick.org/) 14 | 15 | ### NPM 16 | 17 | ``` 18 | $ npm install -g seurat 19 | ``` 20 | 21 | ## Usage 22 | 23 | ``` 24 | $ seurat image/lena.jpg 25 | 26 | ⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣛⣃⡁⠀⠀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⣠⠄⠉ 27 | ⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠜⡻⢿⣿⣿⣿⣿⣿⡟⠛⠛⠛⠛⢻⣿⣿⠓⠏⠈⠋⡆⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⣰⠟⠁⠀⠀ 28 | ⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⣠⣾⢣⣿⡟⢻⣀⣤⣠⣤⣤⣈⡛⠋⠉⣧⡄⠄⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠘⠁⠀⠀⠀⠀ 29 | ⣿⣿⠏⢹⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠁⣫⠴⠞⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠁⠀⠀⠀⠀⠀⣹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠂⠀⠀⠀⠀⠀⠀ 30 | ⣿⠋⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠁⠀⠀⠈⠟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀⠀⠀⠀⢿⣿⣿⡏⠙⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⣠ 31 | ⠁⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠀⠀⠀⣠⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⢸⣿⣿⡇⠀⠈⢿⣿⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⢠⣾⣿ 32 | ⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⢀⡞⠀⠀⠀⠀⣨⣿⣿⡿⢋⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⢸⣿⣿⡇⠀⠀⢈⣽⣿⣟⠁⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿ 33 | ⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⣸⡇⠀⠀⠀⠘⡡⠾⢉⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣼⣿⣿⣇⣠⣶⣿⣿⣿⣿⠀⠀⠀⠀⠀⢠⣾⣿⣿⣿⣿ 34 | ⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⣿⣆⠀⠀⠀⠀⢠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀⣠⣿⣿⣿⣿⣿⣿ 35 | ⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⣿⣿⣧⠀⢠⣾⠟⣡⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⠁⠀⠀⠀⣰⣿⣿⣿⣿⣿⣿⣿ 36 | ⠀⠀⠀⢼⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⣿⣿⢻⡂⠙⣡⡾⢫⡼⣿⢟⠕⠀⠀⠻⠊⠉⠉⠉⢁⣽⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⣁⡼⠃⠀⠀⠀⣰⣿⣿⣿⣿⣿⣿⣿⣿ 37 | ⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⢃⡼⢋⠐⣩⠞⠃⠉⠀⠀⠀⠀⠀⠀⢠⣴⣿⣿⣿⣿⣿⣿⠟⠋⠉⣶⣶⡿⠋⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿ 38 | ⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⣿⡿⠀⠐⣩⠔⠀⠀⠀⠀⠀⠀⠀⠀⠀⣨⣾⣿⣿⣿⣿⣿⣿⣿⣷⠀⠈⣾⠉⠀⠀⠀⠀⠀⢀⣧⣿⣿⣿⣿⣿⣿⣿⣿⣿ 39 | ⠀⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠂⠀⠸⠇⣠⡼⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⠀⢸⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ 40 | ⠀⠀⠀⢸⣿⣿⣿⡀⠀⠀⠀⠀⠀⠀⣰⡃⠹⠎⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⢿⠭⡉⠛⢿⣿⣿⣿⡿⠟⠃⠀⠈⡇⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ 41 | ⠀⠀⠀⢸⣿⣿⣿⠃⠀⠀⠀⠀⠰⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⢋⠀⠀⢀⣦⠈⠚⣿⣿⠏⠀⣤⠀⠀⠀⡇⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ 42 | ⠀⠀⠀⢸⣿⣿⣿⡇⠀⠀⠠⡴⠋⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⠏⢱⣿⣷⣦⣭⣿⣿⣴⢻⣿⣿⣯⡁⠀⠀⠀⣧⠀⠀⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ 43 | ⠀⠀⠀⢸⣿⣿⣿⡇⠀⠀⡉⠁⠀⠀⢀⠀⠀⠀⠀⠀⠢⠀⠀⣰⡟⠁⠀⢸⣿⣿⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿⠀⠀⠀⢿⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ 44 | ⠀⠀⠀⢸⣿⣿⣿⡇⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠊⠁⢠⣴⠏⠀⠀⠀⢸⣿⣿⣿⣿⣿⡏⡷⠜⣿⣿⣿⡏⠀⠀⠀⢸⡄⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ 45 | ⠀⠀⠀⢸⣿⣿⣿⡇⠀⢠⠀⠀⠀⠀⠀⠱⠀⠀⠀⣠⡔⡸⠃⠀⠀⠀⠀⢈⣿⣿⣿⣿⣿⣿⣶⣶⣾⣿⡿⠁⠀⠀⠀⠘⡇⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ 46 | ⠀⠀⠀⢸⣿⣿⣿⣇⠀⡠⠀⠀⠀⢀⠀⠀⠈⣠⣷⢏⠔⠀⠀⠀⠀⠀⠀⠸⠻⣿⣿⣉⠛⣛⣋⣻⣉⡹⠁⠀⠀⠀⠀⠀⣧⣿⣿⣿⣿⣿⣿⣿⣧⣿⣿⣿⣿⣿⣿⣿ 47 | ⠀⠀⠀⢸⣿⣿⣿⡇⠐⠁⠀⠀⠀⠨⢠⠀⠂⠋⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣷⣬⣭⣽⡟⠁⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⠉⣿⣿⣿⣿⣿⣿⣿ 48 | ⠀⠀⠀⢸⣿⣿⣿⢇⡠⠀⠀⠀⠀⢠⠀⠁⠊⡆⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣉⣛⣿⣿⣿⣿⣁⠀⠀⠀⠀⠀⠀⠀⣿⠛⠿⠿⣿⣿⣿⡿⢸⣿⣿⣿⣿⡿⠟⠋ 49 | ⣤⡀⠀⠈⣿⣿⣿⣏⠄⠀⠀⠀⠀⠀⠀⠘⠀⢀⡘⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⢜⣿⣿⣿⣿⣿⣿⣿⣶⣤⡀⠀⠀⠀⣿⣶⣦⣤⣀⠀⠀⡀⢸⣿⣿⡿⠋⠀⠀⠀ 50 | ⠘⣿⡆⠀⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⡌⢠⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⢀⣿⣿⣿⣿⣿⣧⠄⣧⣿⣿⡿⠁⠀⠀⠀⠀ 51 | ⠀⢻⡇⠀⣿⣿⣿⡟⠀⠀⠀⠀⠂⠀⠀⠀⠀⠀⣸⠇⡜⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⢸⣿⣿⣿⣿⣿⠃⣾⣿⣿⣿⠃⠀⠀⠀⠀⠀ 52 | ⠀⢸⣿⠀⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠢⡀⠀⠀⠀⠀⠀⠘⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡸⠿⢿⣿⣿⣿⣶⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 53 | ⠀⢸⣿⠀⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢢⡀⠀⠀⠀⠀⠀⠀⠀⠁⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀⠈⠙⣻⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀ 54 | ⠀⠸⣿⡆⣿⣿⣿⡅⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⠀⠀⠀⠀⢽⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀ 55 | ⠀⠀⣿⡧⣻⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣽⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⡀⢀⡀⠀⠀⠀⠀⢀⠀⠀⠀⠀ 56 | ``` 57 | 58 | \* The braille characters cannot display on Windows. 59 | 60 | ## Options 61 | 62 | ``` 63 | $ seurat --help 64 | 65 | Usage: seurat [options] path/to/image 66 | 67 | -w, --width Number width(cols) of the converted text 68 | -h, --height Number height(rows) of the converted text 69 | -t, --threshold Number threshold for binarization 70 | -i, --invert invert to negative 71 | -o, --output String write the converted text to this file 72 | -p, --print print out the converted text 73 | -v, --version show version 74 | --help show help 75 | ``` 76 | 77 | ## API 78 | 79 | - `convert(src: string|Buffer, opts: object): Promise` 80 | - `src: string` path of the source image file 81 | - `src: Buffer` Buffer of the source image 82 | - `opts: object` 83 | - `width: number` width(cols) of the converted text - default: 60 84 | - `height: number` height(rows) of the converted text 85 | - `threshold: number` threshold for binarization - default: 50(%) 86 | - `invert: boolean` invert to negative 87 | 88 | ## Example 89 | 90 | ```javascript 91 | var seurat = require("seurat"); 92 | 93 | seurat.convert("image/lena.jpg", { 94 | width: 100, height: 50, threshold: 25 95 | }).then(function(result) { 96 | conosle.log(result); 97 | }); 98 | ``` 99 | 100 | ## License 101 | 102 | [MIT](http://mohayonao.mit-license.org/) 103 | --------------------------------------------------------------------------------