We'll be working with the instructions in the GitHub repository at https://www.npmjs.com/package/asciify-image:
Figure 11.1 - An ASCII art representation of me!
Here's the installation step by step:
- Create a new directory called ascii-art.
- cd ascii-art
- npm init. You can accept the defaults provided by npm.
- npm install asciify-image
Now, let's have some fun:
- Place an image in the ascii-art directory, such as a JPEG sized to no more than 200 x 200 pixels or so. Name it image.jpg.
- Create index.js in the directory and open it.
- Enter this code:
const asciify = require('asciify-image')
asciify(__dirname + '/image.jpg', { fit: 'box', width: 25, height: 25}, (err, converted) => {
console.log(err || converted)
})
- Execute the program with node index.js and view your wonderful artwork! Depending on your terminal colors, you may have to work with some of the options to change colors around to display on a light background...