Giter Site home page Giter Site logo

char-dust's Introduction

char-dust

GitHub Pages npm

Convert image to char.

示例 | Demo

由来 | Why char-dust?

夹心酱 jashin char

Usage

yarn add char-dust
# npm install char-dust

Browser

<img id="demo-image" src="xxx" />
import { imageToText, getImageData } from "char-dust";

const imageElement = document.getElementById("demo-image");
const imageData = getImageData(imageElement);
// const text = imageToText(imageData);
// default is "@#&$%863!i1uazvno~;*^+-. "
const text = imageToText(imageData, "@#&$%863!i1uazvno~;*^+-. ");
console.log(text);

Node.js

Method 1: with node-canvas

If you use it in Node.js without document, you need npm install canvas.

yarn add canvas

node-canvas: need node-pre-gyp

Method 2: without native dependencies

yarn add jimp @canvas/image-data
import path from "path";
import jimp from "jimp";
import ImageData from "@canvas/image-data";
import { imageToText } from "char-dust";

const imagePath = path.resolve(__dirname, "./cat-of-the-rebellion.jpg");
jimp.read(imagePath).then((image) => {
  // Magnify 5x
  image.scale(5);
  const imageData = new ImageData(
    Uint8ClampedArray.from(image.bitmap.data),
    image.bitmap.width,
    image.bitmap.height
  );

  const text = imageToText(imageData);
  console.log(text);
});

Functions

  • Read Image
  • Scale Image
  • Convert to Char
  • Console
  • npm package
  • Gif

Todo

  • 直方均衡化

Ref

char-dust's People

Contributors

yunyoujun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.