LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

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]
copy
Brighten the output with a divisor
$ asciitopgm -divisor=[2] [height] [width] [ascii.txt] > [output.pgm]
copy

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
copy
sudo dnf install netpbm
copy
sudo pacman -S netpbm
copy
sudo apk add netpbm
copy
sudo zypper install netpbm
copy
brew install netpbm
copy
nix profile install nixpkgs#netpbm
copy

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

RESOURCES

Copied to clipboard
Kai