tags:

views:

198

answers:

4

How can I automatically generate ascii art?

I mean take a jpg and create a txt file with the ascii art.

Is there an open source library or free software that can be invoked from the command line?

+1  A: 

There are quite a few examples online showing you how to do this. You haven't mentioned which language, but here are a few examples using C#:

Druid
+1  A: 

Check out this CodeProject article, which describes exactly that.

Bernhof
+3  A: 

Which one you use depends on your platform and language of choice, but this is a good one

http://aa-project.sourceforge.net/aalib/

Vinko Vrsalovic
A: 

This depends: there are different kinds of ASCII art.
If you check the color or brightness of every pixel and find a suitable character, the job is very simple (in fact, I did that some years ago - it took very little time).
If you want to find outlines and shapes it becomes a complex problem of image analysis (maybe this can work better with vector images, like svg).

Here's an example from Wikipedia: http://en.wikipedia.org/wiki/ASCII_art

    ____   _____ ______________     ____    ____  ______
   / _  | / ___// ____/  _/  _/    / _  |  / __ \/_  __/
  / /_| | \__ \/ /    / / / /     / /_| | / /_/ / / /   
 / /__| | __/ / /___ / / / /     / /__| |/ / / / / /
/_/   |_/____/\____/___/___/    /_/   |_/_/ |_| /_/

"Oldskool" or "Amiga" style

                          o$ $o
.o$$$$o. .o$$$$o .s$$$$$o.' `".o$$$$$o..o$$$$$o.o$$$$$o.
  .o  `$.$$'   . o$   $"'.o $$   .o  `$. .o  `$$  $$
.o$$.o$$$`"$$$o. $$   .  $$ $$ .o$$.o$$$ $$"o$"   $$
  $$   $$    `$$ $$.  $o.$$ $$   $$   $$ $$  $$.  $$
  $'   $'.o$$$$' `$$$$$$o.' $$   $'   $' $$  $$$" `$
                      $'    $'               $"
"Newskool" style
Kobi