asciitoppm
Convert ASCII art to PPM image
SYNOPSIS
asciitoppm [-black] [-white] [-maxval=maxval] [-plain] [-verbose] [ascii-file]
PARAMETERS
-black
Make spaces in the input represent black pixels instead of white. This is the default behavior.
-white
Make spaces in the input represent white pixels. Overrides -black.
-maxval=maxval
Set the maximum color value in the output PPM image to maxval. The default is 255.
-plain
Generate a plain (ASCII) PPM image instead of a raw (binary) PPM image.
-verbose
Print information about the conversion process to standard error.
ascii-file
The input ASCII file to convert. If not specified, asciitoppm reads from standard input.
DESCRIPTION
The asciitoppm command converts an ASCII representation of an image into a Portable Pixmap (PPM) image format. This allows you to take simple text-based graphics and convert them into a raster image that can be viewed and manipulated with image processing tools. The input to asciitoppm is a text file where each character represents a pixel. The command maps each unique character in the input to a color, with spaces typically representing the background color (black, by default).
asciitoppm is a relatively simple tool, but it can be useful for creating small, stylized images quickly from plain text. It is part of the netpbm package, which provides a suite of utilities for manipulating image files.
This tool is very specific on the correct usage of the input files. The input format is expected to be a plain text file, with the same number of characters per line.
CAVEATS
The input file must contain consistent line lengths to produce a valid PPM image. The characters used in the file determine the colors in the image, and by default color is assigned to each unique character. If the same character is present on multiple lines but should be assigned a different color, this cannot be accomplished with this tool.
EXAMPLE
To convert an ASCII file named 'art.txt' to a PPM image named 'art.ppm':
asciitoppm art.txt > art.ppm
To make spaces represent white pixels:asciitoppm -white art.txt > art.ppm
COLOR MAPPING
asciitoppm automatically assigns colors to the characters present in the input file. The first character encountered is mapped to the first color, the second to the second, and so on. The exact colors are automatically chosen to create a good color separation.
HISTORY
asciitoppm is part of the netpbm package, which dates back to the late 1980s and early 1990s. It was developed as part of a suite of tools for manipulating raster image formats. Its primary usage has been in converting simple text-based images for various purposes.
SEE ALSO
ppmtoascii(1), pnmtoppm(1), netpbm(1)