I remember seeing an email with pictures of bollywood actresses as ascii text. As a completely unnecessary and useless excercise, I decided to try doing it on my own last night (I tend to do such things after a boring day). Surprisingly, I had a working program to create ascii text image from a jpeg within 15 minutes.

The algorithm, as our Maths prof would put it, is idiotically simple. Some characters are "darker" than others. For example, a hash (#) is darker than a dot (.) – it has more black pixels. So, all you need to do is replace each pixel (or set of pixels) with an ascii character depending on the luminosity of the pixel(s). The characters I used are '@', 'p', '*', 'a', '1', ':', '.' and ' ' (space) in decreasing order of darkness. This is a crude method but it gives pretty decent results. Send me a message if you want the source code.

An example (with due apologies to Ms Katrina Kaif)

Output 1- 100 characters per line, viewing in MS Word – Courier New Font (so that every character takes the same width), Font size 6

Output 2 – 200 characters per line (Higher resolution 🙂 ), Font size 4 (Click to see full-size image)

I used CxImage library for loading jpeg images. I've been using this library since college days for all image manipulation stuff. Sadly, it is not being maintained anymore – it is still available as VS 6 project, I had to make a couple of minor changes to build it on VS 2005.