Fractals with characters

The first fractal-text association sample I saw was a fractal image created by Stephen C. Ferguson to which he added a mathematical expression (a fractal formula). Shortly after that, Terry Wright went further, and added a complete poem over one of his images, starting his already famous fractal poems. After seeing those two examples I wondered how difficult it would be to convert a fractal image to plain ASCII characters (after all, language has fractal characteristics too).

As can be imagined, preserving a fractal image using character strings proved to be very difficult by hand. After some frustrating attempts to redraw one of my own fractal images into ASCII art, I did a search through various software collections (it was 1999) and found a small freeware application, called ASCIIPic, which could do the job in a “flash”. This application selects a predefined character according to the shades of an image, and traces its pattern to an ASCII file output automatically. Once the task is done, it’s just a matter of “find and replace” to change certain characters to render it closer to real ASCII art or to select another character that better pleases the eye.

Figure 1: Actual view of ASCIIPic's main window.
Figure 1: Actual view of ASCIIPic’s main window.

Soon, I started to add HTML coding to assign colors to the images and to put them online. That, in a sense, made the files less “complex” because a single character can be used to trace the whole picture, but turned them from normal text archives (6 Kb mean size) into a bitmap equivalent (115 Kb, and even more). I later added some graphic elements to make some of the ASCII pictures a little bit more “artistic”, and even toyed with the idea of adapting sentences and short poems to the fractal patterns. This last thing is still waiting for a good time to be done.

In 2017, ASCIIPic is still available for download: same version, no changes. There’s also an online app that can do the same trick, called Picture to ASCII and found HERE. It creates the ASCII picture from any file you upload, and generate the corresponding code, either as HTML or TXT. Pretty neat, I should add.

Figure 2: Online app PicASCII
Figure 2: Online app PicASCII

After exploring ASCIIPic, I found another bitmap-to-ASCII converter that do the coloring process that I tried before using HTML coding a lot faster, since it directly converts the ASCII file to an HTML one. Thus, there’s no need to code by hand. It’s called HTML Picture Painter; it’s still available online in old software repositories, since nothing else has happened to it since the turn of the century.

Figure 3: HTML Picture Painter main window.
Figure 3: HTML Picture Painter main window.

How it works

In order to produce an acceptable-size ASCII file with ASCIIPic or HTML Picture Painter, the image must not be larger than 100×100 pixels. Otherwise, the resulting ASCII image will span several 640×480 resolution screens. In PicACII you can specify the output size (though the code will be basically the same). Don’t worry about the image’s appearance: the ASCII image will never reach the original image’s resolution or complexity. Also, if you want to see the ASCII nature of the picture, the characters, by default, should not be made smaller than 6 points or so.

What’s more important is to care for the image’s aspect ratio. ASCIIPic, as well as other similar programs I have tried, can hardly keep the image’s original proportions (PicASCII handles this better). So in order to maintain them, you’ll have to alter the image’s proportions in a graphics editor before applying ASCIIPic. Of course, it’s a matter of trial-and-error until you’re satisfied with the results.

Let’s put what we have said into practice. The process requires a few seconds, and a few simple steps. Begin by selecting your fractal picture, then reduce its size to 100×100 using any graphics editor. Be sure to deactivate the MAINTAIN ASPECT RATIO option for non-square images. Although it’s not a requirement, sometimes it could be of some help. Be sure that none of the image’s dimensions exceed 100 pixels.

For this exercise, we’re going to use ASCIIPic, so be sure to save the miniature as a BMP file because ASCIIPic only reads BMP files. ASCIIPic opens up with the interface you saw in Figure 1. Use the INPUT button to load your image, then give a name to the output text file by clicking on the OUTPUT button and selecting a folder where to store the *.txt file.

ASCIIPic have several options you can change to alter the results. Actually, you can bypass the image reduction step given above if you select a lower zoom percentage under the OPTIONS tab. By default, its zoom is set to 100%.

Figure 4: ASCIIPic's OPTIONS tab.
Figure 4: ASCIIPic’s OPTIONS tab.

The BRIGHTNESS control will change the characters used to render the picture. Going to the brighter side will change to less bulky characters (with sufficient white space around them) to produce a ASCII file that gives the impression of lightness. The contrary will happen, of course, when moving the slider control to the darker side.

Finally, if you want to create an ASCII gallery with thumbnails, it’s pretty obvious that a thumbnail-size ASCII counterpart would hardly get close to an incoherent group of Xs and Ms. So what I have done so far is to get a screen capture of a maximized Notepad window showing the corresponding ASCII image, and importing it into a graphics editor (I use XNView, which is pretty good, or Paint Shop Pro) to shrink it to the desired size. It’s also possible to open the text file in a word processor, using font size of, let’s say, 4 points.

That’s pretty much the “technique”. Have fun!