Other Image Protocols

Besides the Kitty graphics protocol, Nash accepts two older image protocols. A program picks the protocol. You do not need to switch anything on.

ProtocolWhat Nash does
iTerm2 inline images (OSC 1337;File=)Draws the image. The nash imgcat command uses this protocol.
SixelDraws the image and tells programs that it supports sixel.

Show an image with nash imgcat

nash imgcat is the quickest way to check that your terminal can show images. It uses the iTerm2 inline image protocol, so it also works in iTerm2.

nash imgcat /path/to/image.png

Without a file name, nash imgcat reads the image from standard input:

cat /path/to/image.png | nash imgcat

Options

OptionWhat it does
--width <WIDTH>Display width. Use auto (default), a number of cells (40), pixels (400px), or a percent of the terminal width (50%).
--height <HEIGHT>Display height, with the same forms as --width.
--no-preserve-aspect-ratioStretch the image to the width and height. The default keeps the aspect ratio.
--position <POSITION>Set the cursor position before the image, in cells. 0,0 is the top left cell.
--no-move-cursorLeave the cursor where it was. The shell prompt can then draw over the image. Add --hold to wait.
--holdWait for Enter, Escape, Ctrl-C, or Ctrl-D after Nash shows the image.
--tmux-passthru <MODE>How to pass the sequence to tmux: disable, enable, or detect.
--max-pixels <N>Scale down images with more pixels per frame. The default is 25000000.
--no-resampleDo not scale down large images. Nash then usually refuses to display them.
--resize <WIDTHxHEIGHT>Resize the image first, for example 800x600. Animated images become a single frame.
--resample-filter <FILTER>nearest, triangle, catmull-rom (default), gaussian, or lanczos3.
--resample-format <FORMAT>Encode resized images as png, jpeg, or the input format (default).
--show-resample-timingPrint how long the resize took.

Run nash imgcat --help for the full text. Nash also accepts the iTerm2 extension doNotMoveCursor=1 in the File sequence. It keeps the cursor in place after the image, like --no-move-cursor.

tmux and multiplexer notes

  • nash imgcat wraps its sequence for tmux passthrough when it detects tmux. tmux does not understand image protocols itself. It removes the image when it redraws the screen, for example while you scroll through its history. Treat tmux support as basic.
  • The iTerm2 image protocol is not fully handled in multiplexer sessions.

Sixel

Nash decodes sixel graphics. In its reply to a device-attributes request, Nash lists sixel support (attribute 4), so tools that detect sixel by that reply find it.

  • After a sixel image, the cursor stays in the left column of the image's last row. If a program turns on the sixel-scrolls-right mode, the cursor moves after the last column of that row instead. iTerm2 images and Kitty images leave the cursor after the last column of the last row.
  • Nash ignores a sixel image whose decoded data is larger than 100 MB, the same limit that applies to Kitty images.

Which protocol should a program use?

If you build a tool, prefer the Kitty graphics protocol. Nash follows its placement rules, answers capability queries, and supports Unicode placeholders for editors and tmux. Use nash imgcat for quick checks and scripts.

Related