ppmtosixel
Convert PPM image files to SIXEL format
TLDR
Convert a PPM image to DEC sixel format
Produce an uncompressed SIXEL file that is much slower to print
Add a left margin of 1.5 inches
Encode control codes in a more portable (although less space-efficient) way
SYNOPSIS
ppmtosixel [-8] [-c cols] [-e] [-g gamma] [-m mode] [-p] [-r rows] [-s] [-t threshold] [-u] [-w] [ppmfile]
PARAMETERS
-8
Instructs ppmtosixel not to limit the output to 8-color Sixel mode. By default, it may prefer 8-color for wider compatibility; specifying -8 allows it to attempt full 256-color output if the terminal supports it.
-c cols
Set the maximum number of output columns for the Sixel data. This can be used to control the width of the generated image on the terminal.
-e
Emit escape sequences to erase the screen before displaying the Sixel graphic. Useful for ensuring the image is displayed cleanly.
-g gamma
Apply gamma correction to the image. gamma is a floating-point number representing the gamma value.
-m mode
Specify the mapping mode for converting colors. Possible modes include direct (default, uses closest color), dither (uses dithering for better color representation), monochrome, and gray.
-p
Output the Sixel palette information as comments within the generated Sixel data stream.
-r rows
Set the maximum number of output rows for the Sixel data. This can be used to control the height of the generated image on the terminal.
-s
Show the raw Sixel string only, without emitting the terminal escape sequences that would normally display the image. Useful for debugging or saving the Sixel data for later use.
-t threshold
Set the dithering threshold for the 'dither' mapping mode. threshold is an integer value affecting how colors are dithered.
-u
Output a monochrome (black and white) Sixel image, discarding all color information.
-w
Do not wrap Sixel lines. By default, Sixel output may wrap if it exceeds the terminal's column limit, which can distort the image.
DESCRIPTION
The ppmtosixel command is a utility from the Netpbm tools collection, designed to convert Portable Pixmap (PPM) image files into the DEC Sixel graphical format. Sixel is a bitmap graphics format originally developed by Digital Equipment Corporation (DEC) in the late 1970s, allowing images to be displayed directly on compatible text terminals by using specific ASCII characters to represent pixels. This command takes a PPM image as input (either from a file or standard input) and outputs the corresponding Sixel escape sequences to standard output. It's particularly useful for displaying simple graphics or plots within a terminal environment that supports Sixel, such as certain configurations of xterm, mlterm, or other modern terminal emulators. While Sixel is a legacy format with limitations in resolution and color depth compared to modern image formats, ppmtosixel provides a bridge for older applications or for users who appreciate the unique capability of in-terminal image display.
CAVEATS
The Sixel format is a legacy graphics standard. To view the output of ppmtosixel, you need a terminal emulator that explicitly supports Sixel graphics, such as certain versions of xterm (with Sixel support compiled in), mlterm, foot, or some configurations of Konsole. It is part of the Netpbm package and relies on its underlying image processing capabilities. Output directly goes to standard output, making it suitable for piping to a terminal, but less so for saving as a standalone image file (unless the file is intended for a Sixel-compatible viewer). Sixel has inherent limitations in resolution and color depth compared to modern image formats.
NETPBM AND SIXEL
ppmtosixel is one of many image format conversion utilities provided by the Netpbm project. Netpbm is a collection of graphics programs and a programming library. The 'Portable Pixmap' (PPM) format, which ppmtosixel takes as input, is one of the foundational 'portable anymap' formats (PBM, PGM, PPM) used internally by Netpbm tools, making it easy to chain operations. Sixel, while old, is still supported by a growing number of modern terminal emulators, often for its unique ability to display graphics directly in a text-based terminal session without needing an external image viewer.
VIEWING SIXEL OUTPUT
To view the Sixel output generated by ppmtosixel, you typically pipe its standard output directly to a Sixel-compatible terminal emulator. For example:cat image.ppm | ppmtosixel
orppmtosixel image.ppm
Ensure your terminal emulator is configured to support Sixel graphics. For xterm, this might involve enabling the Sixel graphics feature (e.g., xterm -ti 340
or compiling with Sixel support).
HISTORY
Sixel graphics were originally introduced by Digital Equipment Corporation (DEC) in the late 1970s, notably with their VT125 and subsequent VT2xx/VT3xx series terminals, as a way to display rudimentary bitmap graphics on text-based terminals. The ppmtosixel utility is part of the widely used Netpbm toolkit, which evolved from the 'pbmplus' package in the late 1980s. Netpbm's purpose is to provide a comprehensive suite of tools for converting and manipulating various graphics formats, and the inclusion of ppmtosixel reflects its commitment to supporting historical and specialized image formats relevant to the Unix ecosystem. Its usage continues in niche applications, particularly for in-terminal data visualization and retro-computing.