img2txt
Convert images to ASCII art
TLDR
Set output column count to a specific value
Set output line count to a specific value
Set output font width to a specific value
Set output font height to a specific value
Set image brightness to a specific value
SYNOPSIS
img2txt [options] [image-files]
PARAMETERS
-C, --charset charset
Select output charset (e.g., ascii, block, katakana)
-d, --dither[=algorithm]
Enable dithering (algorithms: none, xterm, full, floyd, floydsteinh, jarvis)
-f, --foreground
Dither foreground colors only
-b, --background
Dither background colors only
-x, --width chars
Set output width in characters
-y, --height lines
Set output height in lines
-W, --width-pixels pixels
Scale input width to pixels
-H, --height-pixels pixels
Scale input height to pixels
-a, --ansi
Force ANSI output
-k, --colour-mode mode
Color mode (0=mono, 1=ansi, 2=true)
-r, --attributes
Use bold/reverse attributes
-g, --gamma value
Set gamma correction (0.1-10.0)
-p, --packlines
Pack empty lines
-n, --no-dither
Disable dithering
-c, --clear
Clear screen before output
-h, --help
Show help
-v, --version
Show version
DESCRIPTION
img2txt is a command-line tool from the libcaca library that converts raster images into colored ASCII art or text representations. It analyzes image pixels and maps them to characters based on brightness, using dithering algorithms for smooth gradients. Supports output charsets like ASCII, block graphics, or international sets. Ideal for text terminals, logs, or artistic displays.
Key features include adjustable dimensions, ANSI color support, gamma correction, and handling multiple formats (PNG, JPEG, etc.) via underlying libs like libpng/imagemagick. Output can be foreground-only, background-dithered, or full-color. Processes files or stdin, making it script-friendly for batch conversion or live previews.
CAVEATS
Requires fixed-width monospace font with block glyphs for best results. Terminal must support ANSI colors. Large images may produce excessive output; quality varies by image complexity.
EXAMPLES
img2txt image.png
img2txt -x 80 -d floyd image.jpg
cat image.png | img2txt -C block -a
HISTORY
Developed as part of libcaca by Sam Hocevar; first released in 2002-2003. Evolved for cross-platform text graphics, integrated into Debian/Ubuntu repos since early 2000s.
SEE ALSO
caca(1), jp2a(1), aview(1)


