PIXterm

repository·master·Indexed 21 days ago

https://github.com/eliukblau/pixterm

A Go-based terminal utility that renders images (JPEG, PNG, GIF, BMP, TIFF, and WebP) directly in an ANSI terminal using true color and unicode block elements. It supports local files, remote images via HTTP/HTTPS, and multiple dithering modes including blocks and characters.

Tokens
934
Snippets
5
Records
8
Agent score
27%

What's inside pixterm

  1. How PIXterm renders images

    master

    PIXterm renders images in the terminal by recreating pixels using a combination of ANSI character background colors and the unicode lower half block element ().

    Rendering Modes

    • Classic Mode (No Dithering): Uses ANSI background colors and block elements for high fidelity.
    • Dithering with Blocks: Uses block elements with different shades (, , , ) to simulate colors.
    • Dithering with Characters: Uses standard ASCII characters to simulate colors.
    • Dithering with Background Color Disabled (-nobg): Renders dithering without using the ANSI background color.

    Features

    • Transparency: If an image has transparency, an optional matte color can be used for the background.
    • Format Support: JPEG, PNG, GIF, BMP, TIFF, and WebP.
    • Remote Images: Supports fetching images via HTTP/HTTPS.
  2. Requirements for displaying images in PIXterm

    master

    To ensure images render correctly, your environment must meet these requirements:

    1. Terminal Support: Your terminal emulator must support true color.
    2. Font Support: You must use a monospaced font that includes the unicode lower half block element: ▄ (U+2584).
      • For Dithering with Blocks mode, the font must also include: █ (U+2588), ▓ (U+2593), ▒ (U+2592), and ░ (U+2591).
      • Dithering with Characters mode works with standard ASCII characters.
  3. Run or build PIXterm from source

    master

    If you have a local clone of the repository, you can run or build the CLI tool from the repository root using standard Go commands.

    # run
    go run ./cmd/pixterm
    
    # build
    go build -o path/for/binary ./cmd/pixterm
  4. Install PIXterm

    master

    To install the pixterm binary, ensure you have Go version 1.25 or higher installed. You can install it directly into your $GOPATH/bin (or $GOBIN) directory using the following command:

    go install github.com/eliukblau/pixterm/cmd/pixterm@latest
  5. Use the PIXterm CLI to draw images in the terminal

    master

    PIXterm allows you to render images (JPEG, PNG, GIF, BMP, TIFF, WebP) directly in your ANSI terminal using true color. You can provide an image via a local file path or an HTTP/HTTPS URL.

    Usage:

    # From a local file
    pixterm [options] path/to/image.png
    
    # From a URL
    pixterm [options] https://example.com/image.jpg

    Supported Formats:

    • Images: JPEG, PNG, GIF, BMP, TIFF, WebP
    • Protocols: HTTP, HTTPS
    pixterm image.png
  6. Configure PIXterm CLI options

    master

    Use the following flags to control how PIXterm renders images:

    FlagTypeDescription
    -d, --ditheruintDithering mode: 0 (none, default), 1 (with blocks), 2 (with chars)
    -s, --scaleuintScaling method: 0 (resize, default), 1 (fill), 2 (fit)
    -m, --mattestringMatte color for transparency/background in hex format (default: 000000)
    --nobgboolDisable background color (only works in dithering mode; ignores matte color)
    -tr, --rowsuintTerminal rows (optional, $\ge 2$; default is 24 when piping)
    -tc, --colsuintTerminal columns (optional, $\ge 2$; default is 80 when piping)
    --goboolOutput Go code that uses fmt.Print() to render the image
    --versionboolShow PIXterm version
    --creditsboolShow contributor credits