ASCII ALTs

The ALT attribute of an <IMG> element is used to provide content for browsers that cannot render graphics. In general, the ALT attribute should only be used to provide useful information (see the ALT guidelines in Chapter 2). In other words, if you have a bunch of little red ball images as bullets on a page, the ALT text “little red ball” isn’t exactly helpful. In some circumstances, however, you may have an image that you would like to have displayed on both a graphics-capable and a text-only browser. The graphical browser could simply display the image, and the text browser could use an alternative representation rendered as ASCII art. ASCII art is an esoteric pastime on Usenet and the Web. It is the art of arranging characters in the ASCII character set to simulate the shades and nuances of the pixels of an image. Of course, not all images may be rendered successfully as ASCII art. Photographs in particular are difficult to identify in ASCII art form unless they are sufficiently large. Some images translate surprisingly well, however, particularly very graphic images like logos or other graphic elements. Figure 10.7 is an example of a web page that uses ASCII art.

ASCII art may be used to sometimes surprising effect on the Web—and it is quick to download

Figure 10-7. ASCII art may be used to sometimes surprising effect on the Web—and it is quick to download

Requirements

The Gimp
AA-Lib

Solution

Text-only browsers simply plop the ALT text into the document in ...

Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.