LinuxCommandLibrary

img2sixel

Convert images to sixel graphics

TLDR

Display an image in the terminal

$ img2sixel [path/to/image]
copy

Resize the image to the specified width and height before displaying it
$ img2sixel [[-w|--width]] [number] [[-h|--height]] [number] [path/to/image]
copy

SYNOPSIS

img2sixel [options] image_file...

PARAMETERS

-w
    Sets the maximum width of the output image in pixels. Aspect ratio is maintained by default.

-h
    Sets the maximum height of the output image in pixels. Aspect ratio is maintained by default.

-p
    Specifies the maximum number of colors to use in the SIXEL palette, typically a value from 1 to 256. Controls color quantization.

-k
    Keeps the aspect ratio of the input image, even if both width and height are specified. This is often the default behavior.

-o
    Writes the generated SIXEL data to the specified file instead of standard output (stdout).

-u
    Displays usage information and exits.

-v
    Enables verbose output, showing progress and detailed information during conversion.

DESCRIPTION

img2sixel is a command-line utility that converts various image formats (like PNG, JPEG, GIF, BMP, etc.) into SIXEL graphics.
SIXEL is an ancient but recently revitalized bitmap graphics format, originally developed by Digital Equipment Corporation (DEC) in the 1980s for their VT-series terminals. The tool outputs a series of terminal escape sequences representing the image, which can then be rendered directly within a compatible terminal emulator (e.g., xterm, mlterm, mintty, foot, wezterm).

Its primary purpose is to enable users to display images directly within the command-line interface, which is particularly useful for scripting, remote SSH sessions, or integrating image previews into CLI applications. img2sixel handles aspects like color quantization, dithering, and image resizing to adapt the input image for optimal display on a character-based terminal environment. It is a core component of the libsixel project, aiming to bring powerful graphics capabilities to modern terminals.

CAVEATS

img2sixel requires a SIXEL-compatible terminal emulator to display images directly. Without one, the output will appear as unreadable escape sequences.

The quality and fidelity of the displayed image are highly dependent on the terminal's capabilities, including its color depth and character cell resolution.

Performance may vary for very large images or complex conversions.

The SIXEL output consists of terminal escape sequences, which means it will interfere with or be corrupted by other text output if not handled carefully (e.g., redirecting only the SIXEL output).

TERMINAL REQUIREMENTS

To view images converted by img2sixel, your terminal emulator must explicitly support the SIXEL graphics protocol. Popular choices include xterm (when compiled with SIXEL support), mlterm, mintty, foot, and wezterm. Always verify your terminal's capabilities if images do not display correctly.

OUTPUT MECHANISM

The command outputs a stream of ANSI escape sequences (specifically DEC private modes for SIXEL) to standard output. These sequences are interpreted by a SIXEL-aware terminal to draw the image. This means you can pipe the output to a file or another command, or simply let your terminal process it directly.

HISTORY

The SIXEL graphics format originated with Digital Equipment Corporation (DEC) in the 1980s, primarily for their VT240, VT330, and VT340 series of graphics terminals. It allowed bitmap images to be transmitted over serial lines and rendered directly in the terminal window. After a period of decline with the rise of GUI environments, SIXEL has experienced a resurgence in recent years, largely driven by the libsixel project. This library, along with its associated command-line tool img2sixel, aims to modernize and standardize SIXEL support, making it accessible on contemporary terminal emulators and allowing for image display in CLI environments, SSH sessions, and embedded systems. img2sixel is the flagship tool for converting various image formats into this classic yet revived graphics format.

SEE ALSO

sixel(5), xterm(1), mlterm(1)

Copied to clipboard