Summary
Claude Code's Linux checkImage command excludes image/bmp from its grep pattern. This silently breaks image paste for all WSL2 users, because Windows copies images as BMP by default and WSLg forwards that format unchanged via Wayland.
A one-line fix would resolve this for every WSL2 user.
Root Cause
In cli.js, the Linux clipboard detection command is:
xclip -selection clipboard -t TARGETS -o 2>/dev/null \
| grep -E "image/(png|jpeg|jpg|gif|webp)" \
|| wl-paste -l 2>/dev/null \
| grep -E "image/(png|jpeg|jpg|gif|webp)"
image/bmp is missing from the pattern. When the clipboard contains BMP (the Windows default), checkImage returns exit code 1 and SD1() silently returns null — no error, no feedback.
Proposed Fix
Add bmp to the grep pattern:
- grep -E "image/(png|jpeg|jpg|gif|webp)"
+ grep -E "image/(png|jpeg|jpg|gif|webp|bmp)"
And add a BMP conversion path in saveImage (since the rest of the pipeline expects PNG):
wl-paste --type image/bmp 2>/dev/null | convert bmp:- png:"${TMPFILE}" 2>/dev/null
Or simply add BMP to the check and let ImageMagick/Sharp handle the conversion downstream.
Evidence
Tested on WSL2 (Ubuntu), Windows Terminal, Claude Code 2.1.42, Node v22.22.0:
| Command |
Result |
wl-paste -l |
image/bmp (Windows default) |
wl-paste --type image/bmp | file - |
Valid BMP image data |
checkImage (as-is) |
Exit 1 — grep misses image/bmp |
checkImage (with bmp added) |
Exit 0 |
| Manual BMP→PNG + Alt+V |
Works perfectly |
The full checkImage → saveImage → base64 pipeline works once BMP is converted to PNG. The only failure point is the grep pattern.
Impact
This affects every WSL2 user who tries to paste images. WSL2 is a common developer environment, and this is the #1 reported image paste issue:
Current Workaround
A background daemon (clip2png --watch) that polls the Wayland clipboard every 2 seconds and converts BMP→PNG via ImageMagick. Combined with a custom keybinding (alt+v → chat:imagePaste since Windows Terminal intercepts the default ctrl+v), this makes image paste work on WSL2. But it requires ImageMagick, a watcher script, Claude Code hooks, and custom keybindings — all to work around a missing format in a grep pattern.
Environment
- Platform: WSL2 (Ubuntu) on Windows 11
- Terminal: Windows Terminal
- Claude Code: 2.1.42
- Node: v22.22.0
- Clipboard: WSLg Wayland (
wl-paste/wl-copy)
Summary
Claude Code's Linux
checkImagecommand excludesimage/bmpfrom its grep pattern. This silently breaks image paste for all WSL2 users, because Windows copies images as BMP by default and WSLg forwards that format unchanged via Wayland.A one-line fix would resolve this for every WSL2 user.
Root Cause
In
cli.js, the Linux clipboard detection command is:image/bmpis missing from the pattern. When the clipboard contains BMP (the Windows default),checkImagereturns exit code 1 andSD1()silently returnsnull— no error, no feedback.Proposed Fix
Add
bmpto the grep pattern:And add a BMP conversion path in
saveImage(since the rest of the pipeline expects PNG):Or simply add BMP to the check and let ImageMagick/Sharp handle the conversion downstream.
Evidence
Tested on WSL2 (Ubuntu), Windows Terminal, Claude Code 2.1.42, Node v22.22.0:
wl-paste -limage/bmp(Windows default)wl-paste --type image/bmp | file -checkImage(as-is)image/bmpcheckImage(with bmp added)The full
checkImage→saveImage→ base64 pipeline works once BMP is converted to PNG. The only failure point is the grep pattern.Impact
This affects every WSL2 user who tries to paste images. WSL2 is a common developer environment, and this is the #1 reported image paste issue:
Current Workaround
A background daemon (
clip2png --watch) that polls the Wayland clipboard every 2 seconds and converts BMP→PNG via ImageMagick. Combined with a custom keybinding (alt+v→chat:imagePastesince Windows Terminal intercepts the defaultctrl+v), this makes image paste work on WSL2. But it requires ImageMagick, a watcher script, Claude Code hooks, and custom keybindings — all to work around a missing format in a grep pattern.Environment
wl-paste/wl-copy)