dsh-paste-image
Manifest validPaste any image into DeepSeek Harness: converts XPM/BMP/TIFF and MIME-lying images to real PNG in the renderer
dsh-paste-image
Paste or drop almost any image into DeepSeek Harness — even when the clipboard says image/xpm or lies about the MIME type.
Why this exists
The DSH desktop client (Electron/Chromium) accepts exactly four attachment types: image/png, image/jpeg, image/webp and image/gif. Anything else gives you the red rejection:
仅支持 PNG、JPG、WebP、GIF
That whitelist breaks two things that happen all the time on Linux:
- Screenshots declared as XPM. Some screenshot tools, notably on Ubuntu/Wayland, put the image on the clipboard with the type
image/xpm. The pixels are fine; the label is not on the whitelist, so the paste is rejected. - BMP bytes wearing a PNG label. Some applications hand over a BMP (or TIFF) payload while declaring
image/png. The declared type passes the whitelist check, the decoder later fails, and you get the same red error.
dsh-paste-image handles both cases inside the renderer: it looks at the actual bytes, decodes what the clipboard really contains, re-encodes it as PNG, and hands the result back to the normal attachment channel.
How it works
- Capture.
install()registerspasteanddroplisteners ondocumentin the capture phase, so the plugin sees the event before the composer does. - Sniff.
handle()reads theFileobjects fromclipboardDataordataTransfer, andsniff()identifies the real format from magic bytes — not from the declared MIME type. - Re-encode.
normalize()lets native files through untouched. Everything else is decoded (dedicated XPM and BMP decoders, or the browser's own codec), drawn onto a canvas capped at 4096 px on the longest side, and exported asimage/pngwith a.pngfile name. - Reroute.
handle()dispatches a syntheticdropevent carrying the newFileat[data-composer-card], which is the same path a real drag-and-drop takes. A__dshPasteImageReroutedmarker stops the plugin from intercepting its own event.
All of this is client-side. There is no host process, no clipboard polling and no network request.
Supported formats
| Format | Typical declared type | What happens |
|---|---|---|
| PNG | image/png | Passed through unchanged |
| JPEG / JFIF | image/jpeg | Passed through unchanged |
| WebP | image/webp | Passed through unchanged |
| GIF | image/gif | Passed through unchanged |
| XPM (XPM3 text) | image/xpm | Decoded by decodeXpm(), re-encoded as PNG |
| BMP / DIB (24/32-bit, uncompressed) | image/bmp | Browser decode first, decodeBmp() as fallback, re-encoded as PNG |
| TIFF | image/tiff | Detected by magic bytes; decoded only if the browser ships a TIFF codec (Chromium does not), otherwise the original is passed through |
AVIF, ICO, CUR, SVG, HEIC, other image/* | image/... | Decoded by the browser when it can, then re-encoded as PNG; otherwise the original is passed through |
Pass-through only happens when the magic bytes match one of the four native types and the declared type agrees (or is empty). A file whose bytes are JPEG but which claims image/png is re-encoded as a real PNG, so the declared type can no longer lie.
A file is considered at all when its MIME type starts with image/ or its name ends in .png, .jpg, .jpeg, .jfif, .gif, .webp, .bmp, .dib, .tif, .tiff, .xpm, .avif, .ico, .cur or .svg. Non-image files in the same paste are forwarded untouched.
Install
Not published to npm. Install from GitHub:
dsh plugin --profile <profile> add github:pengtang1024/dsh-paste-image
For local development, point the profile at your checkout:
dsh plugin --profile <profile> add file:/absolute/path/to/dsh-paste-image
Replace <profile> with the profile your app runs. Reload the page after installing (Ctrl+R, or Cmd+R on macOS). The client module is only injected when the renderer loads, so a freshly installed plugin intercepts nothing until you reload.
Verify it works
Run the repository checks:
cd dsh-paste-image
npm test
npm run check
npm test runs the Node test suite (5 tests at 0.1.0) covering magic-byte sniffing, candidate detection, the BMP decoder, the BMP-labelled-PNG conversion and native pass-through. npm run check syntax-checks client.js and lib/index.js.
Then check the real flow:
- Reload the DSH window.
- Take a screenshot with your usual tool and paste it into the composer, or drop an image file onto it.
- The attachment appears. Open DevTools (
Ctrl+Shift+I) → Console, switch the level to Verbose, and look for a line like:
[dsh-paste-image] image/xpm -> image/png 1440x900
If conversion fails, the plugin keeps the original file and logs keep original (...) instead.
Limitations
- XPM: XPM3 text format only. The parser reads the
ccolour key; other keys such asm,gandsare ignored. Colours are resolved by the browser's CSS parser, so palette names that are not valid CSS colours, such as the multi-wordlight gray, fall back to opaque black. - BMP: 24- or 32-bit, uncompressed (
BI_RGB),BITMAPINFOHEADERor newer only. RLE, 1/4/8/16-bit images and OS/2 headers are not supported. For 32-bit files the fourth byte is taken as alpha, so files that leave it at zero can come out transparent. - Other codecs: AVIF, ICO, CUR, SVG and HEIC rely on the browser decoder; TIFF is detected but Chromium does not decode it. When the browser cannot decode a file, the original is passed through and the host rejects it as before.
- Size: converted images are scaled down to at most 4096 px on the longest side. Native files passed through untouched are not resized.
- File count: one paste or drop may contain at most 8 files. Larger batches are left entirely to the native path.
- Flattening: a converted image becomes a single PNG frame. Animation, EXIF metadata and embedded colour profiles are not preserved.
- Scope: only the
pasteanddroppaths are covered. The file picker and other insertion paths keep their native behaviour.
Security and privacy
- Everything runs in the renderer. The plugin makes no network requests, uploads nothing and stores nothing.
- There is no background process, no clipboard polling and no change to DSH host code.
- Image bytes are read only from the paste or drop event, decoded locally, and handed back to the same window.
- The decoders are small, but they do process untrusted input. If you find a crash or a parsing bug, see SECURITY.md.
Documentation
- How it works — event flow, decoder internals and a function-by-function code map.
- Troubleshooting — common failures and how to read the logs.
- Contributing — development setup, tests and style.
License
MIT © 2026 pengtang1024. See LICENSE.
Comments
Loading…
Similar plugins
by qgynisc
DeepSeek Harness Web GUI 插件:粘贴图片即在文字中插入 image-1.png 内联胶囊,悬浮名字预览缩略图,自动编号(文字中插图 / hover 预览)
★ 0
MIT
JavaScript
Oct 21, 2026
dsh plugin --profile web add dsh-inline-pastesby thezavtrak-a11y
Draw on a pasted screenshot in the DeepSeek Harness web GUI: pen, arrow, rectangle, ellipse and text stamps, flattened into a PNG attachment at the image native resolution.
★ 0
MIT
JavaScript
Oct 4, 2026
dsh plugin --profile web add dsh-image-annotateby liujia-io
Paperclip image-picker button for the DeepSeek Harness web composer - pick reference images via the system file dialog and feed them into the official attachment pipeline.
★ 0
MIT
JavaScript
Sep 5, 2026
dsh plugin --profile web add dsh-image-pickerby uckkk
图片处理:读取尺寸/格式、缩放与格式转换(内置 ffmpeg)
★ 0
MIT
JavaScript
Aug 19, 2026
dsh plugin --profile web add dsh-imageby cfour-hi
将一张图片转化为 DeepSeek Harness 主题
★ 0
MIT
JavaScript
Nov 13, 2026
dsh plugin --profile web add @cfour-hi/dsh-plugin-skinxby Ssrs-Pro-Max
DeepSeek Harness plugin: shows oversized images to the model at readable resolution by tiling them before admission.
★ 0
MIT
JavaScript
Oct 24, 2026
dsh plugin --profile web add dsh-image-tiler