Convert Images & Videos To ASCII Art – aalib.js

Category: Javascript , Recommended , Text | October 9, 2017
Author: mir3z
Views Total: 91
Official Page: Go to website
Last Update: October 9, 2017
License: MIT

Preview:

Convert Images & Videos To ASCII Art – aalib.js

Description:

aalib.js is a dependency-free JavaScript library that automatically converts images and videos into static or moving ASCII art.

Install it via NPM:

$ npm install aalib.js --save

How to use it:

Install and import the aalib.js library into your project.

<script src="aalib.js"></script>

Convert an image into ASCII Art:

aalib.read.image.fromURL("sample.png")
  .pipe(aalib.aa({ width: 200, height: 160 }))
  .pipe(aalib.render.html())
  .pipe(function (el) {
      document.body.appendChild(el);
  })
  .end();

Convert an HTML5 video into ASCII art using canvas:

<video src="sample.mp4" controls></video>
<canvas id="video-scene"></canvas>
aalib.read.video.fromVideoElement(document.querySelector("video"))
  .pipe(aalib.aa({ width: 165, height: 68 }))
  .pipe(aalib.render.canvas({
      width: 696,
      height: 476,
      el: document.querySelector("#video-scene")
  }))
  .end();