claude-image-view README

项目的 README,来自 github.com/jarrodwatts/claude-image-view。合并为一个 markdown 文件:README.md。

Claude Image View

A Claude Code mod that shows the images you paste, so you see thumbnails above your prompt instead of bare [Image #1] tags.

License Stars

Claude Image View in action

Install

Inside Claude Code, run:

/plugin marketplace add jarrodwatts/claude-image-view
/plugin install image-view
/reload-plugins

That's it. Paste an image into the prompt and its thumbnail appears above the input.

Prefer the terminal?
claude plugin marketplace add jarrodwatts/claude-image-view
claude plugin install image-view@claude-image-view

Then run /reload-plugins inside a session, or start a new one.

What You See

Paste one or more images and a row of thumbnails sits above the prompt, each labelled with the number of its tag:

╭────────────────────────╮ ╭────────────╮
│                        │ │            │
│      (screenshot)      │ │  (photo)   │
│                        │ │            │
│           #1           │ │     #2     │
╰────────────────────────╯ ╰────────────╯
❯ why is the header misaligned here [Image #1] vs [Image #2]

How It Works

Claude Code saves every pasted image to a cache folder for the session, as <tmp>/<project>/<session>/images/<n>.<ext> in the format it was pasted (.png, .webp, .jpg, ...), and puts an [Image #n] tag in the prompt. Claude Image View is a mod:

  1. Every 200ms it reads the prompt box and looks for [Image #n] tags. It checks on a timer because pasting an image doesn't raise an edit event.
  2. For each tag it finds the cached file. Kitty graphics only draws PNG from a file, so on macOS anything else (WebP, JPEG, HEIC, GIF, TIFF) is converted once with sips to <session>/image-view-<n>.png. It reads the size from the PNG header.
  3. It draws the thumbnails in the band above the prompt. Where Claude Code draws pictures (see Terminal Support) it uses Claude Code's Image element, and the terminal reads the file itself, so the image data never passes through the mod.
  4. Anywhere else it decodes the PNG itself, averages it down to a small thumbnail, and draws it in colored half blocks (▀) with Claude Code's Raster element. It's lower resolution than a real picture, but it's the picture.

Terminal Support

Claude Code, not the mod, decides whether a terminal gets real pictures. It draws them in kitty (0.28+) and Ghostty, and turns them off inside tmux and screen and in background sessions. Every other terminal gets half-block thumbnails.

Terminal Thumbnail
Ghostty, kitty Real picture
iTerm2, Terminal.app, WezTerm, VS Code, Windows Terminal, Orca, most others Half blocks
Inside tmux or screen, even in Ghostty or kitty Half blocks
Agent view and background sessions Half blocks, or real pictures with CLAUDE_CODE_FORCE_TERMINAL_IMAGES (below)

Some terminals speak the kitty graphics protocol but still get half blocks, because Claude Code trusts terminals by name (anthropics/claude-code#99566), or because it doesn't wrap images for tmux passthrough yet (anthropics/claude-code#100146). Those are Claude Code limits, so a fix there brings real pictures to the mod with no change here.

CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1 makes Claude Code draw pictures in any terminal. Only set it if your terminal supports the kitty protocol's Unicode placeholders. VS Code's terminal, for one, doesn't yet, and shows a grid of colored squares instead (xtermjs/xterm.js#5711).

Security

Claude Image View is local-only. It makes no network requests. It reads the prompt box, lists Claude Code's temp folder to find the current session's image cache, and reads each pasted image (up to Claude Code's 4 MiB read limit). For a non-PNG paste it runs sips and writes one PNG thumbnail into that session's temp folder. On macOS and Linux it runs id -u once to find that temp folder. It also reads a few terminal variables (TERM, TERM_PROGRAM, TMUX and similar) to tell which kind of thumbnail Claude Code can draw.

Run claude plugin validate on the repo to see every event it hooks and every call it makes.

Requirements

The Claude Desktop app already previews pasted images, so the mod draws nothing there.

Troubleshooting

Nothing appears when I paste. Run /plugin and check the dim line under the tabs lists image-view as an active mod. If it isn't listed, run /reload-plugins. If it still isn't, look for an image-view: hooks module did not load line above the first prompt of a new session: that means your Claude Code is too old for the mod, so update it.

The tile says "no preview". The mod couldn't find the cached file, or the paste isn't a PNG and you're not on macOS, where sips converts it. Claude Code may have moved where it stores pasted images. Please open an issue with your Claude Code version.

The tile is blocky. Claude Code doesn't draw pictures in your terminal, so the mod draws the picture in colored half blocks. See Terminal Support.

The tile shows [Image #1] text instead of the picture. The mod expected Claude Code to draw a picture, but it didn't. That happens in terminals that look like Ghostty or kitty but aren't, such as Herdr (anthropics/claude-code#101306), or in kitty older than 0.28. Set CLAUDE_IMAGE_VIEW_RENDERER=blocks in the environment you start Claude Code from. CLAUDE_IMAGE_VIEW_RENDERER=image forces real pictures the other way.

The tile is a grid of colored squares. CLAUDE_CODE_FORCE_TERMINAL_IMAGES is set in a terminal that can't draw Unicode placeholders, such as VS Code's. Unset it to get half-block thumbnails.

I want real pictures in agent view or a background session. Claude Code turns terminal images off there. If you attach from Ghostty or kitty, turn them back on in the env block of ~/.claude/settings.json, then start a new session:

"env": { "CLAUDE_CODE_FORCE_TERMINAL_IMAGES": "1" }

Development

git clone https://github.com/jarrodwatts/claude-image-view
cd claude-image-view

# Load it for one session without installing
claude --plugin-dir .

# Check it and run the tests
claude plugin validate .
claude plugin test .

Claude Code writes the API types into .claude-plugin/types/ the first time it loads the mod, and tsc -p . type-checks it from then on.

License

MIT. See LICENSE.

Star History

Star History Chart

claude-image-view (jarrodwatts/claude-image-view)

正在搜索数据库…

这是什么?Claude Image View 是一个 Claude Code mod,它会显示你粘贴到提示框里的图片缩略图,而不是光秃秃的 [Image #1] 文本标签。
这是独立应用,还是 Claude Code 的插件?它是一个加载在现有 Claude Code 终端会话里的插件(mod),不是独立应用;Claude Code 甚至会在首次加载时为这个 mod 生成 API 类型。
怎么把它跑起来?在 Claude Code 里安装它,然后只要往提示框粘贴一张图片,缩略图就会自动出现在输入框上方;如果什么都没显示,运行 /reload-plugins 或新开一个会话。
要让它真正工作需要什么?你需要带 mods 支持的 Claude Code v2.1.287 或更新版本,运行在 macOS 或 Linux 上,并且使用支持 kitty 图形协议的终端,比如 Ghostty 或 kitty。
缩略图预览总能工作吗?不能。不支持 kitty 图形协议的终端只会显示原始的 [Image #n] 文本而不是图片;Claude Code 还会对后台或代理视图会话禁用终端图片,除非你在 settings.json 里重新启用。
这个 mod 会把我粘贴的图片发到别处吗?不会。它只在本地运行:不发起任何网络请求,也不写任何文件,只读取提示框内容和 Claude Code 已经为该会话缓存到本地的 PNG。
它在 Claude Desktop 应用里有什么作用吗?没有。Claude Desktop 本身就会预览粘贴的图片,所以这个 mod 在那里什么都不画。
它究竟是怎么找到并渲染图片的?它每 200 毫秒扫描一次提示框里的 [Image #n] 标签,把每个标签与 Claude Code 为该会话缓存的 PNG 匹配,从 PNG 头读取尺寸,再用 Claude Code 的 Image 元素把它画在提示框上方。
“无预览”占位块是什么意思?它表示这个 mod 没能找到该标签对应的缓存 PNG,通常是因为 Claude Code 更改了粘贴图片的存放位置;建议的解决办法是带上你的 Claude Code 版本号开一个 issue。
大小
0.4 MB
星标
288
时长
2个月
提交 · 90 天