One more thing on my bucket list that I finally got around to doing, that I've been wanting to do for a long, long time was to write a tool where I could upload an image, and it would automatically convert the image into ASCII art. ASCII art is pretty cool, because it's like an impressionist painting. At a certain distance, some strange details come to life. Being able to convert any image to ASCII art would be awesome. I got this working late last week, which you can check out here.
Turns out, there's existing libraries that do this already. I've found three, with pros and cons as follows:
aa-lib - the original library, no longer being maintained, handles a variety of image formats, capable of rendering in black and white, but does not have a command line interface
libcaca - a newer library, also handles a variety of image formats, can only render in color, but does have a command line interface
jp2a - also a newer library, only handles jpegs, can render in color or black and white, and has a command line interface
I ended up going with jp2a, because I needed a library that could render in black and white via the command line. I paired it up with ImageMagick, to convert images to JPEG before feeding it into jp2a.
The following is an example of the output.
NXXXXXXXXXXXXXXXXXNNNNNNXXKKK0O000KKXXXXNNXXXXXXXXXKKXXXKX0XKO0KKKKKKKKKXXKKKKK0kdlloooooddodxxxddxkkkkkkkkkkO000000000K NNNNNNXNNNNNNNXXXNNNNNNNNXK0000KKKKXNNNNXXXXXXXXXXXXXXXXXXKK00KKKKXXXKKXXXXXXXXKKkolooooodooddxxdxxxkkkkkkkkkO00000000KK KXXXNNNNNNNNNNNNNNNNNNNNNXKKKKXXXXXXNNNNNNNNNNXNXXXXXXXXXXXKKKXXKKXXXXXXXXXXXXXXXKOdooooodoodxxxxxxxkkkkOOkkOO00000000KK XXXXXNXXXNNXXNNXNNNNWWNNXXXXXKKKXXNNNNNNNNNNNNNNNNXXXXXKKXKKKKKKKXKKXXXXXXXXXXXXXXXOdoooddoodxxxxxxkkkkOOOOkO00000000KKK KXXXXXNNNNNNNNNNNWWWWWNXXXNNXXXXNNNNNNNNNNNNNNNNXXXXXKKKKK0KK0000KKKKXXKXXXXXXXXXXXKkddddddddxxkxxxkkOOOOOOOO00000000KKK KKKKKKKKKKKKXXNNNWWWWNNXNNNNNNXNNNNNNNNNNNNNNXXXKKKKK000K0OK0OOkO0000KK00KXXXXXXXXXXOxddddddxxkkkxxkkOOOOOOOO00000000KKK XXXXKKKKKKKKXXNNNNNNNNNNNNNXNNNNWWNNNNNNNNNXXKKK000OOOOO0OOOkxxxxkOO0K0kkO0KXXXXXXXXKOkxxxddxkkkxxxkkkOOOOOOO00000000KKK XXXXXXXKKXXXXXNNNNNNNNNNNNNNNNNWWWNNNNNNNNNXKK0OOOkkkkkkkkkkdddddxxxO0kxdxkk0XXXNNXXXKkxxxddxkxkxxxkkkkOOOOO000000000KKK XXXXXXXXXXXXXNNNNNNNNNNNWWWWWWWWWWWNNNNNNNXXK0OOkkxxxdddddddoooooddxxdooodddkOXNNNNXXKOxxxdxxkkkxxxkkkkOOOOO000000000KKK XXXXXXXXXXXXXNNNNNNNNNWWWWWWWWWWNNNNNNNNNXX00Okkxxxddddoooollllllllllllllooodx0NNNNXXX0kxxxxxxdkkxkkkkkOOOOOO00000000KKK XXXXXXXXXXXXXNNNNNNNNWWWWWWWWWWWNNNNNNNNXK0OkkkxxxdddooolllcccccccccccccclloddkKNNXXXKOxxxxxxxdkxxkkkkkOOOOO00000000KKKK NXXXXXXXXXXNNNNNNNNNNWWWWWWWWWWWNNNNNNXK0OOkkkxxxdxddolllllcccc::::ccccccccloox0XNXXXKkxxxxxxxkkkkkkkkkOOOOO0000K000KKKK NNXNNXXXXXXNNNNNNNNNNWWWWWWWWWWWNNNNXKK0OOkkkOOOO000OOkkxdolcc:::::::::::ccclodkXXKKK0kxxxxxkxxkkkkOkkOOOOOO000000000KKK NNNNNXNNXXXNNNNNNNNNNNWWWWWWWWWWWWNXK00OOkkkkOOOO0OOOO00000Oxocc:::::::;::cclloxKXX000kxxxxxkxxkkxkkOOOOOOOO000000000KKK NNNNNNNNXNXNNNNNNNNNNNWWWWWWWWWWWNNXK0OOkkkkkkkkxxxddooodxxkOOkoc::::::::cldkkO0KKK0kkxkkxxxkxkkkkkkOOOOOOOO0000K000KKKK NNNNNNNNXXXXXNNNNNNNNNNNNWWWWWWWWNXK0OOkkkkxxxxxxddoolcclloooddxolc:::cldxOOOkxkOK0OxxxxxxxxkkkkkkkkOOOOOOO00000K00KKKKX NNNNNNNXXXXXXNNNNNNNX00KXNWWWWWWWNX0OkkxxxxxkkkO00OkOOkkxdooolloolc::clolllllllodOkxxxxxxxxxkxkkkkkkOOOOOOO00000KK0KKKKK kkkkkkkkkkkkkkOOOO0XK0KKKXNNNWWWNNKOkkxxdoddxxkOO0Okk0KK00Odooollc:::cllllooddoodxddxxxxxxxxkkkkxkkkOOOOOOO000KK00KKKKKX :;;;;,,,'''''......O00KK00KXXNWWNX0Okxxdoolllloooooooodddoolooollc:;::llodOKK00kxxdddxxxxxddxxxxxxkkkOOOOOO000K00K0KKKKX lllccc::;,;;;,,,,;:OK0K0O0KXKXNNNK0Okxxdoollllcccccccccccccccllcc:;;;:cllodddddodxddddxdddddxkxxxxkkkOOO0OO000K0K00KKKKK dxOkkkxxxdllccccc:cOX00O0KKKK0KXX0OOkxxddolllccc:::::::::::cccccc::;;::cccccccccoxxxxxxxxxxxkkkxxkkkOOOO000000KK00KKKKKK dddddooooolllccccccONKOO0K00K00K00OOkkxxdoollccc:::::::::::ccccccc:;;;::::::::::lxxxxxxxxxoccldxkkOOOOO0000000KK00KKKKKK dddddooooollllcccclONK0OOOOk0K0000OOkkxxddoollcc:::::::::::cclllc::;;;;:::::::::lxxxkkxd, 'dkkkOOOO00000KKKK0KKKKKX ddddddooooollllllll0NKXX0OkkkOO00OOOOkkxxdoolllcc:::::::::cooolcc:::;;;;:;:::;::okxkkko. . .,:kOOO0O000000KKKKKKKKKXX xxddddddooooollllloxOkOXNXOkkkO00OOOOkkxxxdooolcc::::::::cddoc:::::;;,;;:;;:;;:cxkkkko. ....:,o00000000000KKKKKKKKXXX xxxxxddddddddddoooox00kXWWNXKKK000OOOkkxxxddoollcc:::::::lddlcldxdl::;;:;:::;;:dOkkko .....,:;O000000000KKKKKKKKXXXX KK0000000KXXXXKKKOdkNNNNNWWWWNK00OOOOkkkxxxddoollccccc:::cldxdddodoccllc::::;:dOOOkd. .... .'c,lKKKKK0000KKKKKKKXXXXX NK0kkxxxxOXNNKKKKOxOWWWWWWWXXNXK00OOOkkkkxxdddoolllccccccclooddddoooddocc::::dOOOOd. ........c;;OKKKKKK00KKKKKKKXXXXX XX0xddddx0K0O00000OKWWWWWWNKKXKKK00OOOkkxxxxddooollllllllllooooooodoooollc::oOOOOk... ...''..'::,dKKKKKKKKKKXXKXXXXXXX XX0xxddddO00kdO00KXNWWWWWWWWNNKKK00OOOkkkxxxdddoooollloollollllloooooollcccokOOOO:.,' ....,'..':l;:0KKKKKKKKKXXXXXXXXXX XXOxdddookOkOdl0XXXWWWWWWWWNXXKKKK00OOkkkkxxxxddddooooodxxxkkkkkxxxxxxxolclkO000o.';' ....';,..';lc::OKKKKKKKXXXXXXXXXXN K0xolcc::clloxxk00XXXXXXXKK000KKKKK00OOkkkkkxxxdddoooodxkOOkkxxdxxxdddolclkOO00O..,;......,;'.',;cl::cKKKKKKKXXXXXXXXXNN kkOOOkxxO00OOKKOxxxKKKKKK0kkO0KKKKKKK00OOOkkkxxxdddddooddddddddoooooolllokOO000;.';, ..''';:'.';;clcc:dKKKKKXXXXXXXXXXNN XXXKKK0kO00000KX0oxKKOxoloxO00KKKKKKKK00OOOOkkkxxddddddddooodddddoollllcxO0000d..,;...''',::'';c::ooc:cKKKXXXXXXXXXNNNNN KKXXXXXXKKNNNWWWNxxdlclodxO000KKK00K0000000OOOkkxxxxdddddooodddddoooll,. .';co'.';,...,'',c;.,:c;;ooc::k0KXXXXXXXXXXXNNN WWWWWWWWWNNK0OxdlccllodxkO000KKKK000000000000OOOkkxxxxddddoooooooolll;.. ....'...','';l,,:c:,,odlccxXXXXXXXXXXXNNNNN WWWWWWWN0kodllllooddxxkkO000KKKK0000000000000000OOOkkxxxdddooooooool:................''',:o,:c:,.,xxolo0NNXXXXNXXNNNNNNN WWWNKOxodxxxdooddxxkkkOOO00KKKKKK000000000000OOOOOOOOkkkxxxdddddddo;,,,'''..............,:c;::,.'cO00KNNNNNNNNNXNNNNNNNN X0kdooooxkOkkxxxkkkOOOO0000KKKKKKK0000000000O0OOkkkkkkxkkkkkxxxooocc;;;;;,,,'''''........',;;,..:xXNWWNNNNNNNNNNNNNNNNNN kOkkk00kxxOOOOOOOOOOO00000KKKKKKKK000000000000OOOkkxkkkkkkkkxdkdloollcc::::;;;;,,,,,'''''',,,,,:dONWWWWNNNNNNNNNNNNNNNNN dx00000K0OkOOO00OOO0000000KKKKKKKKK0000000000OOOOOOkkkkkkkkxxdxdoldodlllllcccc:::::;;;;,;,;;,;;:d0NWWWWNNNNNNNNNNNNNNNNN dxk0KOkO000O0OO0000000000KKKKKKKKKKK0000000OOOOOOOOkkkkOOkkxxxxkdddxodooooooollllllcccc::::::;;::l0NNWNNNNNNNNNNNNNNNNNN ddxk0K0kkO00K00O0OOO0O000KKKKKKKKKKKKK000000OOOOOOOOOOOOOkkxxxkOxxdxxxddddddddddddooooollllcccc::ccxXWWWNNNNNNNNNNNNNNNN ooodk0K0kkkO0KK00OOOOOO0000KKKKKKKKKKKK000000OOOOOOOOOOOOkkxxxxOkkxdkxkxxdddxxxxxxxxxdxdddoooollllcccxXNNNNNNNNNNNNNNNNN ooodxOKK0kxkO0KK00OkOOOO000KKKKKKKKKKKKK000000OOOOOOOOOOOkkkkkkOkkkxkkkkxxxxxxkkkkkkkkkxxxxxdddooolllllKNNNNNNNNNWNNWNNN
Written on April 6, 2017