Skip to content

Commit a9f4d96

Browse files
authored
docs: add documentation for image preview (#882)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a new "Image Preview" section to the sidebar navigation for easier access. - **Documentation** - Introduced comprehensive documentation explaining terminal-based image previews, supported protocols, terminal compatibility, and fallback mechanisms. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent b56933e commit a9f4d96

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

website/astro.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ export default defineConfig({
103103
label: 'Tutorial',
104104
link: '/getting-started/tutorial/',
105105
},
106+
{
107+
label: 'Image Preview',
108+
link: '/getting-started/image-preview/',
109+
}
106110
],
107111
},
108112
{
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Image Preview
3+
description: Learn how image preview works in superfile and how terminal compatibility is determined.
4+
head:
5+
- tag: title
6+
content: Image Preview | superfile
7+
---
8+
9+
This tutorial will teach you how to use superfile’s image preview feature step by step.
10+
11+
## What is Image Preview?
12+
13+
superfile supports image previews directly in your terminal using several display protocols. When supported, images can be shown inline without any external viewer.
14+
15+
---
16+
17+
## Terminal Compatibility
18+
19+
superfile automatically detects your terminal using the `$TERM` and `$TERM_PROGRAM` environment variables. We support rendering on the following terminals:
20+
21+
| Terminal | Protocol | Image Preview Support |
22+
|-----------------------|------------------|------------------------|
23+
| **kitty** | Kitty protocol ||
24+
| **WezTerm** | Kitty protocol ||
25+
| **Ghostty** | Kitty protocol ||
26+
| **iTerm2** | Inline images ||
27+
| **Konsole** | Inline images ||
28+
| **VSCode** | Inline images ||
29+
| **Tabby** | Inline images ||
30+
| **Hyper** | Inline images ||
31+
| **Mintty** | Inline images ||
32+
| **foot** | Sixel graphics ||
33+
| **Black Box** | Sixel graphics ||
34+
35+
> ✅ means full support for inline image preview using Kitty protocol
36+
> ❌ means image preview is currently not supported
37+
38+
---
39+
40+
## Supported Protocols
41+
42+
superfile supports the following rendering protocols and will automatically choose the best one based on your terminal:
43+
44+
| Protocol Name | Description | Status |
45+
|-------------------|-----------------------------------------------------------------------------------------------|-------------|
46+
| **Kitty protocol** | Most capable, pixel-accurate rendering with transparency and scaling support. | ✅ Preferred|
47+
| **Sixel** | Old standard used in DEC terminals and some modern ones like foot. ||
48+
| **iTerm2 inline** | iTerm2’s proprietary image format, used in Tabby, Hyper, etc. ||
49+
| **ANSI** | Fallback text rendering using ANSI blocks or metadata only. | ✅ Always |
50+
51+
---
52+
53+
## Terminal Detection and Pixel Size
54+
55+
superfile detects terminal capabilities by inspecting:
56+
57+
- `$TERM`
58+
- `$TERM_PROGRAM`
59+
60+
These variables help us decide whether advanced rendering might be possible. However, real support is confirmed at runtime using terminal queries.
61+
62+
To scale images correctly, superfile sends the following escape code:
63+
64+
```
65+
\x1b[16t
66+
```
67+
68+
This sequence queries the terminal for the size of each **cell in pixels**. superfile uses the result to:
69+
70+
- Maintain correct image aspect ratio
71+
- Avoid distortions in previews
72+
- Adapt to terminal resizes
73+
74+
If your terminal does not support `\x1b[16t`, we fallback to default assumptions like `10×20 px per cell`.
75+
76+
## Graceful Fallback to ANSI
77+
78+
When advanced image preview isn't supported (for example, when the terminal doesn't support the Kitty protocol), superfile gracefully falls back to an ANSI-based preview using color-coded blocks.
79+
80+
This ensures a consistent and reliable experience across all terminal environments.

0 commit comments

Comments
 (0)