asciitopgm

Convert ASCII art to PGM grayscale image

TLDR

Convert ASCII art to PGM (note: height comes before width)
$ asciitopgm [height] [width] < [ascii.txt] > [output.pgm]
Brighten the output with a divisor
$ asciitopgm -divisor=[2] [height] [width] [ascii.txt] > [output.pgm]

SYNOPSIS

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

DESCRIPTION

asciitopgm converts ASCII art text to PGM (Portable Graymap) image format. Each character becomes one pixel; a large character such as a capital M produces a dark pixel, while a small one such as a period produces a light pixel.This is useful for converting legacy ASCII artwork to image formats or for creating images from text patterns. Output values range from 0 to a maximum of 127.

PARAMETERS

height

Output image height in pixels (number of rows)
width
Output image width in pixels (number of columns)
asciifile
Input ASCII file (reads from stdin if omitted)
-divisor integer
Divide each character's blackness value, brightening the output. Default is 1; larger positive values produce brighter images.

INSTALL

sudo apt install netpbm
sudo dnf install netpbm
sudo pacman -S netpbm
sudo apk add netpbm
sudo zypper install netpbm
brew install netpbm
nix profile install nixpkgs#netpbm

CAVEATS

Character-to-grayscale mapping may not produce optimal results for all ASCII art styles. Output dimensions must be specified manually.

HISTORY

asciitopgm is part of the Netpbm image processing toolkit, which evolved from PBMPLUS in the late 1980s.

SEE ALSO

pgmtopbm(1), pnmtopng(1), img2txt(1)

RESOURCES

Homepage · Documentation