Using NodeJS to asciify images

Published Dec 16, 2015Last updated Feb 10, 2017
Using NodeJS to asciify images

In this post, I'll describe how to use image-to-ascii for converting images into ASCII art. This is built by me and it is open-sourced on GitHub.

It's super easy to use. Let's take a look.

Prerequisites

You have to install GraphicsMagick before using this package:

$ sudo apt-get install graphicsmagick # Ubuntu
$ brew install graphicsmagick         # Mac OS X

Usage

After the prerequisites are installed, you can install the module: npm install image-to-ascii. Then you can start ASCIIfying images.

Let's use this Octocat in our tests. The url of the image is https://octodex.github.com/images/saint-nicktocat.jpg.

So, to convert this image into ASCII art, you'll have to do the following below:

// Load the library
var img2ascii = require("image-to-ascii");

// Convert an octocat into ascii :)
img2ascii("https://octodex.github.com/images/saint-nicktocat.jpg", function (err, result) {
    console.log(result);
})

The result is:

Saint Nicktocat

This is the default behavior. We can modify it using an object instead of a string.

Don't forget to browse the code and documentation on GitHub... and ASCIIfy the world!

Discover and read more posts from Johnny B. (Ionică Bizău)
get started
Enjoy this post?

Leave a like and comment for Johnny

1
2