Convert raw image data to ascii art!
install
npm install ascii-pixels
usage
input raw image data, and optionally set contrast or invert colors
var options = contrast: 128 // range -255 to +255 invert: true // invert brightness var ascii =
The raw image data has the following format:
var imageData = data: frameData width: width height: height
You may optionally provide the pixel format: imageData.format = 'RGB24'
, by default it is RGB32
.
examples
Any format is supported as long as you can get the raw image data. Here are a few examples:
node using jpeg-js
var fs = var jpeg = var asciiPixels = var buffer = fs var imageData = jpeg var ascii = console
browser using canvas
var asciiPixels = var img = img { var canvas = document canvaswidth = imgwidth canvasheight = imgheight var context = canvas context var imageData = context var ascii = console} imgsrc = './nodejs-logo.png'
node using canvas
var fs = var Canvas = var asciiPixels = var img = imgsrc = fs var canvas = imgwidth imgheightvar context = canvas context var imageData = context var ascii = console
sample output
C,
8@@@
0@@@
0@@@
@@ .::. CG 8@@@ G8 ...
t@@@@@@@@1 .:::::::;. @@@@@@@@@@ ,@@@@@@@@; . .
@@@@@ff@@@@@ ::::;;::;::: @@@@@0G@@@@@ @@@@@GG@@@@@ . ..,
@@@@ @@@@ ::::;;:;;;:: 0@@@ 8@@@ 8@@@ ,, @@, . ...
@@@@ @@@@ :::;;;;;;;:: 8@@@t ;@@@@ 8@@@L . ... ,
@@@, :@@@ ,:::;;:::,. i@@@@@@@@@@f ,@@@@@@8 . . ..
,,,: .@@@@; 8@@@ . ,
credit
This project is based on the awesome ascii-camera by Andrei Gheorghe
license
MIT