Unified facade for terminal inline image display.
Auto-detects the best available graphics protocol (Kitty, iTerm2, Sixel) and encodes image data as a terminal escape sequence.
Usage
# Display from file path
{:ok, escape_seq} = Image.display("logo.png", width: 20, height: 10)
IO.write(escape_seq)
# Display raw PNG bytes
{:ok, escape_seq} = Image.display(png_binary, format: :png)
# Force a specific protocol
{:ok, escape_seq} = Image.display("photo.jpg", protocol: :iterm2)
# Check support
Image.supported?() #=> true
Image.detect_protocol() #=> :kitty
Summary
Functions
Detects the best available image protocol for the current terminal.
Encodes an image for display in the terminal.
Returns true if any image protocol is supported.
Types
@type display_opts() :: [ width: pos_integer(), height: pos_integer(), protocol: protocol(), format: :png | :jpeg | :gif, preserve_aspect: boolean(), z_index: integer() ]
@type protocol() :: :kitty | :iterm2 | :sixel | :unsupported
Functions
@spec detect_protocol() :: protocol()
Detects the best available image protocol for the current terminal.
Priority: Kitty > iTerm2 > Sixel > :unsupported.
@spec display(binary(), display_opts()) :: {:ok, binary()} | {:error, term()}
Encodes an image for display in the terminal.
The source can be a file path (string) or raw image bytes (binary). Returns the escape sequence to write to the terminal.
Options
:width- Width in terminal cells:height- Height in terminal cells:protocol- Override auto-detected protocol:format- Image format hint (:png, :jpeg, :gif):preserve_aspect- Preserve aspect ratio (default: true):z_index- Z-index layer for Kitty protocol (default: 0)
@spec supported?() :: boolean()
Returns true if any image protocol is supported.