# asciitopgm

Updated: 15 January 2026
Table Of Contents

## NAME

asciitopgm - convert ASCII graphics into a PGM

## SYNOPSIS

    asciitopgm
    [-divisor=integer]
    height width [asciifile]

Minimum unique abbreviation of option is acceptable. You may use double hyphens instead of single hyphen to denote options. You may use white space in place of the equals sign to separate an option name from its value.

## DESCRIPTION

This program is part of Netpbm.

asciitopgm converts a text grayscale image to PGM. A text grayscale image is a way that people generated a grayscale graphical image with a black on white text printer in the early days. Each character printed is one pixel. A large character such as a capital M is a dark pixel, while a small character such as a period is a light pixel. A space is a fully white pixel. The viewer stands far back from the printed page so as to blur the text and sees a grayscale image. A common novelty use of the technique was to print out a photograph of a person's face in text.

Obviously, asciitopgm assumes a certain font in assigning a brightness value to a character.

asciitopgm considers ASCII control characters to be all white (except for newline, which is never a pixel but rather indicates the end of a raster row as you would expect). For a lower case character, It assigns a special brightnesses which has nothing to do with what it looks like printed.

asciitopgm takes the ASCII character code from the lower 7 bits of each input byte. But it warns you if the most significant bit of any input byte is not zero.

The output image is height pixels high by width pixels wide, truncating and padding with white on the right and bottom as necessary.

In a sort of reminiscence of Fortran line printer carriage control, where a line starts with + (plus), asciitopgm combines it with the previous row of output instead of generating a new row. This allows a larger range of gray values. (In Fortran carriage control, the first character of every line sent to the printer tells how much to advance the paper, with + meaning not at all, so that the rest of the characters on the line overstrike the ones already on the paper. What asciitopgm does is rather different in that asciitopgm does not reserve the first character of every line that way. If the first character is anything but +, asciitopgm considers it just to be the first character of the image.

The maxval of the output image is 127.

If you're looking for something that creates an image of text, with that text specified in ASCII, that is something quite different. Use pbmtext for that.

## OPTIONS

In addition to the options common to all programs based on libnetpbm (most notably -quiet, see Common Options), asciitopgm recognizes the following command line option:

-divisor=integer
  Specify the value by which the blackness of an input character is divided. This is an integer value. Larger values produce brighter output images.

  The value must be positive.

  The default value is 1.

  You can use this to adjust the brightness of the output: for example, if the image is too dark, increase the divisor.

  Before Netpbm 11.14 (March 2006), this must be abbreviated -d, separated from its value by a space and not an equals sign, and appear before the non-option arguments.

## SEE ALSO

pbmtoascii, pbmtext, pgm

## AUTHOR

Wilson H. Bent. Jr. (whb@usc.edu)

## Table Of Contents

- SYNOPSIS
- DESCRIPTION
- OPTIONS
- SEE ALSO
- AUTHOR