Creating artistic images with ASCII art
The Art of Letters
![](/var/linux_magazin/storage/images/issues/2014/168/ascii-art/78002271_7.png/626432-1-eng-US/78002271_7.png_medium.png)
Creating images from letters and numbers is a complex matter, unless you have the right tools at hand.
ASCII artists are often genuine tinkerers: With meticulous attention, they create images, and even movies, solely from letters and digits. The combination of simple means and complexity of images is always fascinating. This extravagant art form goes back to the first half of the 20th century and has been known since the 1960s as ASCII art.
The images only use character sets without non-standard characters. These Latin characters are based on the English alphabet and later on the American Standard Code for Information Interchange (ASCII). They contain uppercase and lowercase letters, basic delimiters, and control characters that come from the world of the telegraph. These characters can be found on almost any computer, allowing users to display the image in an identical manner wherever they are.
Artistic opportunities arise in particular by leveraging the amount of black in the various characters. The artist creates transitions between light and dark, and individual shapes, such as arches and curves, through different shades. The human brain's ability to abstract and recognize images using patterns assures the desired effect.
Tools
The central libraries on Linux for generating these images are AAlib and libcaca. The former stands for "ASCII Art Library" [1] and only generates images in grayscale; however, libcaca [2] adds color to the game. If you want to experiment to see the power of these two libraries, you can install the libaa-bin, bb, and caca-utils packages.
All three packages contain several examples. Both aafire
and cacafire
decorate a terminal with a fireplace (Figure 1), whereas aatest
, bb
, and cacademo
impressively demonstrate animations, filters, and transitions in fonts and colors. You can conjure up a clock on the screen with cacaclock
(Figure 2).
Viewing and Converting
The aview
program lets you view images in PNM format. For other formats, such as PNG or JPEG, however, asciiview
from the same package or cacaview
from the caca-utils package are better choices. They prepare the images in the background for viewing on-screen (Figure 3).
The aview
and asciiview
programs display the images with 7-bit characters; the -eight
option lets you switch to 8-bit mode, and -extended
tells the two programs to use 256 characters.
The best approach to converting images is with the GIMP image editing program. To do this, open the desired image, and export it using File | Export. In the drop-down menu, select ASCII art (*txt, *.ansi, *.text). However, GIMP generates relatively large files.
Even the reverse path from alphabet soup to a raster image works with the right tools, but first you need Ditaa (Diagrams through ASCII art) [3]. This Java program converts images into shapes and graphs by combining traditional media with its own extensions, which define the colors and shapes of the elements. Listing 1 shows some example data, and Figure 4 shows the results.
Listing 1
Using Ditaa
Ditaa generates the labels from the text in the box. Strings that start with a lowercase c define the background color. Color codes can be specified either as text designators or as RGB data.
Horizontal and vertical lines are created with the minus and pipe characters. A plus sign indicates corners, which you can optionally round off with a slash character. To convert the text file to an image, enter:
ditaa <inputfile.txt> <outputfile.png>
Alternatives are asciitopgm
and the Python-aafigure Python module [4]. The former can be found in the netpbm package, and the latter provides a complete class for integration into your own projects.
Speech Bubbles and Banners
The Cowsay and Cowthink programs offer more entertainment value. Both can be found in the Debian cowsay package. The tools generate images of cows that output text in a separate bubble.
Cowsay generates a speech bubble and Cowthink a thought bubble, as the names imply. Both programs accept a series of switches to display the cow in various moods and variants, including -b
for Borg mode, -d
for a dead cow, -g
for a hungry cow, and -p
for paranoia mode (Listing 2).
Listing 2
Speech Bubble
The apt-get package manager includes an Easter egg that appears when you type apt-get moo
(Listing 3).
Listing 3
Easter Egg
Fans of the steam age might want to install the sl (steam locomotive) package, which shows animated steam locomotives running from right to left in the terminal. Originally intended as a joke triggered by mistyping the ls
command, the gimmick has now achieved cult status.
The program accepts various switches that customize the display: -a
calls the engineer to help you, -l
draws a smaller train, and -F
lets the train fly (Figure 5).
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.