How to make ASCII ART effect using Imagemagick?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

How to make ASCII ART effect using Imagemagick?

Post by agriz »

Hi,

Is it possible to create Ascii Image for an original image. I search around the web, I didn't get much clue to do it using imagemagick.

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to make ASCII ART effect using Imagemagick?

Post by fmw42 »

You would need to get the average graylevel of each letter in the alphabet (caps and lowercase and other characters) for some fixed width font. Put that into a database (or array). Then measure the average graylevel of your image in same size blocks as your alphabet. Then replace each block of the image with the closest graylevel character.

I don't believe that IM can do that right now. Though Anthony may have scripted something like that. See his scripts at http://www.imagemagick.org/Usage/scripts/. I think he may have done something similar but using small photos rather than characters. Perhaps he will have more information or reference to some other software.

see also lots of online generators:'

http://www.glassgiant.com/ascii/
http://ascii.mastervb.net/
http://www.ascii-art-generator.org/
http://www.degraeve.com/img2txt.php
http://sporkforge.com/imaging/ascii.php
http://www.typorganism.com/asciiomatic/

http://www.fileguru.com/apps/ascii_art_maker_pro_apk
http://aa-project.sourceforge.net/aalib/
http://www.codeproject.com/KB/web-image ... Fc%5F.aspx

see also
http://en.wikipedia.org/wiki/ASCII_art_converters
http://www.cse.cuhk.edu.hk/~ttwong/pape ... ciiart.pdf
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to make ASCII ART effect using Imagemagick?

Post by anthony »

There was some older posts where we were generating grey squares, and then replacing those squares with various sized circles. This is the same, but replacing with letters, rather than circles.
viewtopic.php?f=1&t=17389&start=15

However a slight improvement may be to not just map intensity but also some of the letters shape. That is making things like diagonal lines match slashes and forward slashes. This is more complicated though I have seen some ascii-art programs (sorry no pointers on hand) that can do this.

Similarly using multiple overlaid characters can also generate darker areas than just using # or @ charcaters on their own.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply