[Back to the Floodgap main page] Return to Floodgap Software


Once again everything retro is cool, and so is ASCII art, the once maligned practice of drawing cartoon figures, cute icons and conspicuous bits of the female anatomy in a humble assortment of printable 7-bit ASCII characters. Despite this, however, there are good reasons for still being able to render images in printable ASCII:

ppmascii (intentionally not named "ppm to ascii" or "ppm 2 ascii" due to similar sounding tools) is an attempt to rectify some of the problems of the existing bitmap-to-ASCII renderers, namely, poor output and difficulty with modification or improvement. Being 100% Perl, requiring no modules, ppmascii is slower than a compiled approach, but barely perceptably so on modern hardware; moreover, being a script, you can hack it up for your particular terminal's features and customize it for better local function. You can also change the characters used for "pixels" (ppmascii was calibrated against as wide a range of monospaced fonts that I had available, but it may not match your tastes, so it's easy to change). Furthermore, ppmascii includes many features that other renderers and converters do not, such as built-in Floyd-Steinberg dithering, input-stage image controls and simple aspect scaling. This allows you to get very nice image output with hardly any work, but with the flexibility of built-in tinkering to taste.

Finally, you can use any image toolkit such as netpbm or ImageMagick to generate portable anymaps for ppmascii's consumption; this is a trivial file format to process and is generated by a tremendous number of tools. Although the name implies only PPMs are supported, ppmascii will actually read and process P1, P2, P3, P5 and P6-type files.

Here are the major options (or you can say ppmascii -help):

Most people may want to play with the "palette." This can be done by changing the @elements list. Although I have tried to make a "spectrum" that works on as wide a range of monospace/non-proportional terminal fonts (under X, Mac OS X and Windows) as possible, I imagine people will have their own preferences and thus you can specify them there, or completely warp the list to render something totally crazy. By default, the list is 16 elements long, so the default rendering is in "16 shades of grey."

To give you an idea of the output, here are a few sample renderings using the de facto image processing standard portrait of Lenna (this is a PNG conversion of the original TIFF; the TIFF and PNG are scaled to 80 pixels wide for purposes of terminal width). The command lines I used for each example are stated. As with all such optical illusions, they are best appreciated from a distance. ;-)

ppmascii is distributed under the Floodgap Free Software License. Originally it was written for Perl 4.036 and may even still run under Perl 4, but this most current version is only supported on 5.005 or better. It should run on any system where Perl is supported.

This version 1.2 corrects a math error that can sometimes cause a divide-by-zero condition, and improves compatibility on Perl 5.8 and later. Last modified 5/19/2010.

Please send me your comments. One day I might also release my old pnmtotek utility for Tektronix terminals if there is enough interest.

Cameron Kaiser