While working across headless Linux servers or command-line workflows, previewing images, animated GIFs, or video files typically requires launching a graphical desktop session or transferring files via SCP. The timg command-line utility solves this by rendering high-resolution graphics and video playback directly inside modern terminal emulators. By taking advantage of protocols such as Kitty graphics, iTerm2 inline images, Sixel, or standard 24-bit direct color block characters, timg provides instant media previews without leaving your shell.
Supported Graphics Protocols and Compatibility
timg automatically probes your terminal capabilities to select the highest-fidelity rendering pipeline available:
- Kitty Graphics Protocol: Native pixel-perfect hardware rendering in Kitty, Ghostty, and WezTerm.
- iTerm2 Graphics Protocol: High-resolution inline graphics supported in iTerm2, WezTerm, and modern console tools.
- Sixel Graphics: Hardware palette graphics supported by foot, Alacritty (with patch), and XTerm.
- Unicode Half-Blocks: High-resolution fallback utilizing 24-bit true-colour ANSI escape sequences and block characters (
â–€andâ–„), compatible with virtually every modern terminal emulator.
Installation Instructions
On Ubuntu and Debian
sudo apt update
sudo apt install timg
On Fedora and RHEL / Rocky Linux
sudo dnf install timg
On Arch Linux
sudo pacman -S timg
Step-by-Step Practical Usage
Step 1: Rendering a Standard Image
To display an image directly inside your terminal window, pass the file path to timg:
timg screenshot.png
timg automatically resizes the output to fit your active terminal window dimensions while preserving the original aspect ratio.
Step 2: Customising Output Geometry and Dimensions
You can constrain the width and height of the rendered image using the -g (geometry) flag:
timg -g 80x25 architecture_diagram.jpg
This restricts the output to 80 columns wide by 25 terminal rows high.
Step 3: Rendering Animated GIFs and Looping
timg plays animated GIFs natively in the terminal at their recorded frame rate. To play a GIF and loop it three times, run:
timg --loops=3 animation.gif
Step 4: Playing Video Files Directly in the Shell
If compiled with FFmpeg support (standard across official distro packages), timg renders full video files with smooth terminal frame updates:
timg demo_recording.mp4
Press Ctrl + C at any time during playback to exit cleanly back to your prompt.
Step 5: Displaying Multi-Image Grids
To preview multiple assets side-by-side in a responsive grid layout:
timg --grid=3x2 asset1.png asset2.png asset3.png asset4.png
Comparison of Terminal Image Viewers
| Tool | Supported Protocols | Video Playback | Multi-Image Grid | Resource Footprint | Best For |
|---|---|---|---|---|---|
timg |
Kitty, iTerm2, Sixel, ANSI Blocks | Yes (Native FFmpeg) | Yes | Very Low (C++20) | Modern high-resolution image and video previews |
chafa |
Sixel, Kitty, iTerm2, ANSI Symbols | Via external piping | No | Extremely Low (C) | Legacy terminal character-art rendering |
feh |
X11 Window only | No | Yes (Desktop window) | Low | Minimalist desktop image viewing |
kitty +kitten icat |
Kitty Protocol only | No | No | Negligible | Dedicated Kitty terminal users |
Troubleshooting and Performance Tips
- Forcing a Specific Protocol: If auto-detection chooses block characters inside an emulator that supports Kitty graphics, force the engine with
timg -pk image.png(Kitty) ortimg -pi image.png(iTerm2). - SSH Remote Rendering: When connected over SSH, Kitty protocol transfers image bytes directly through the encrypted stream without X11 forwarding or VNC requirements.
- Flicker Reduction in Videos: In standard Unicode block mode, high frame-rate videos may cause flicker on slower terminal emulators. Use
--frame-delay=50msto stabilise rendering.