dsh-crop-zoom: Enlarge Small Text in Screenshots Before Model Processing

Introduction

When asking models to read screenshots in DeepSeek Harness (dsh), the common approach is to feed the entire image into the visual capability. Large images are often scaled down before entering the model; consequently, 10–11px item names and status bar numbers in games often have their strokes blur together after scaling. The model cannot recover lost pixel details by repeatedly reading the same image. crop-zoom takes a different path: before the model reads the image, it crops specified regions locally, scales them up by an integer factor, and passes the new image to read_image. It uses geometric preprocessing to trade for readability, rather than relying on OCR or repeated full-image inference.

What is this

dsh-crop-zoom (GitHub: 07210905/crop-zoom) is a community-maintained dsh plugin that also provides a standalone CLI of the same name. It registers the crop_zoom tool within the Harness; the entire process is handled locally without network access, model calls, or built-in OCR. The only dependency is sharp (libvips), which is loaded lazily to avoid hindering Harness startup if native modules are missing. The runtime environment requires Node ≥ 22, and the license is MIT. The plugin is categorized as “Model Inference” in the SkillHub directory.

Core Features

The following introduces the capabilities actually provided by the plugin, all sourced from the official README.

crop_zoom Tool: Crops 1–8 rectangular regions from a local image using source pixel coordinates, scales them up by an integer factor using a selected interpolation kernel (up to 16× per operation), outputs PNGs, and returns the paths. The model should then use read_image to read the results. The text returned by the tool only describes the geometry and the output paths, intentionally serving as metadata rather than the “answer.”

Automatic Scaling: The scale parameter can be omitted. The tool calculates the magnification factor based on target (default 1600) so that the longer edge of the region reaches the target pixel count, without exceeding 16×.

Multi-Region Sheet Assembly: By default, multiple regions are stacked vertically into a single annotated PNG, allowing for a single follow-up read. Sheet generation can be disabled to output a separate file for each region.

Interpolation Modes: bicubic (default, preserves glyph outlines), nearest (integer pixel copying, beneficial for distinguishing monospaced glyphs like 0 and D), lanczos, mitchell. The README suggests using two modes complementarily to view ambiguous glyphs.

Preview Coordinate Correction: If coordinates were measured on a scaled-down preview, previewWidth can be passed to automatically map them back to the source image dimensions.

CLI: Shares the same engine as the plugin, suitable for scripting or debugging.

Installation and Activation

To install as a dsh plugin, use the commands in the documentation (do not manually construct github:owner/repo):

dsh plugin --profile <profile> add dsh-crop-zoom     # from a registry
dsh plugin --profile <profile> add ./dsh-crop-zoom   # from a local checkout

Restart the application after installation; crop_zoom will be provided to the model upon request.

Standalone CLI:

npm install -g dsh-crop-zoom
crop-zoom -i shot.png -r 1178,588,64,24 -s 16 -o label.png

The plugin accesses local files with the permissions of the current dsh process. Please review the repository source code and the MIT license before installation to ensure compliance with your environment policies.

Typical Usage

Single region, automatic scaling to ~1600px on the longer edge:

{ "path": "C:\\shots\\raid.png", "regions": [{ "x": 1178, "y": 588, "width": 64, "height": 24 }] }

Two regions combined into a sheet, increasing the target longer edge:

{ "path": "C:\\shots\\raid.png",
  "regions": [{ "x": 80, "y": 430, "width": 540, "height": 300, "label": "rank board" },
              { "x": 875, "y": 155, "width": 450, "height": 660, "label": "gear" }],
  "target": 2400 }

Fixed 16× scaling using nearest mode to separate easily confused glyphs:

{ "path": "C:\\shots\\raid.png", "regions": [{ "x": 1444, "y": 373, "width": 96, "height": 42 }],
  "scale": 16, "mode": "nearest" }

After the tool writes the file, a typical return message will describe the kernel, source coordinates, and magnification factors for each region, and prompt the use of read_image to read the sheet path, rather than answering based solely on the geometric summary.

Main Parameters

Name Type Default Meaning
path string — Absolute path to the source image, required
regions array — 1–8 regions, in sheet order; each item is {x, y, width, height, label?}, in source image pixels
scale integer — Integer factor 1–16; calculated from target if omitted
target integer 1600 Target pixel count for the longer edge when scale is absent, max factor 16×
mode enum bicubic bicubic | nearest | lanczos | mitchell
sheet boolean true Whether to stack into a single annotated PNG
outPath string Temp dir Output path, must end with .png
previewWidth integer — Preview image width, used for coordinate conversion

The CLI supports -i, repeatable -r, -s, -t, -m, -o, --preview-width, --no-sheet, --json, etc., with semantics consistent with the table above.

How It Works and Limitations

Through the steps above, the engine roughly does three things: decodes the source image once according to the post-EXIF-rotation display dimensions; extracts each region and then resizes it by an integer factor to minimize resampling interference on fine strokes; and optionally composites a sheet with geometric descriptions.

Limitations to note:

  • Local files only; path does not support remote URLs.
  • Output is always PNG; up to 8 regions per operation, and up to 16× per region.
  • Sheet annotations are ASCII; non-Latin descriptions should be placed in the region’s label field rather than relying on rendering them onto the image (which depends on fontconfig / librsvg).

Conclusion

If your agent frequently misreads small text due to screenshot downsampling, crop-zoom fixes “crop first, then zoom, then read” as a Harness tool, which is usually less costly than repeated full-image inference. Community directory page: crop-zoom on SkillHub; Source code and full documentation: 07210905/crop-zoom.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye