Clipsmith ocr
Run native macOS image OCR through Vision.framework via pyobjc bridge (same engine family used by Preview/Live Text), with Chinese+English recognition defaults and deterministic CLI execution. Use when you need to extract text from local images on macOS — including screenshots, photos, or scanned documents — and want output to stdout or a text file. Also known as image-to-text or read-text-from-image.From its SKILL.md
npx -y skills add OctopusGarage/clipsmith --skill clipsmith-ocrAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
8.6 KB, ~1.9k tokens by cl100k_base, as published. Nobody here has run it
clipsmith-ocr
Deterministic local OCR executor backed by Apple Vision.framework. No network calls, no third-party cloud, no API keys. Recognition runs on-device using the same ML model as Preview and Live Text.
Two implementation details that affect output and are not in Apple's public docs:
- Bounding-box coordinate origin is lower-left (not upper-left like screen coordinates). The script compensates by sorting on
-(y + height)descending, thenxascending to produce correct reading order. - Language correction (
setUsesLanguageCorrection_) is always enabled — Vision silently applies a language model to fix likely OCR errors based on the primary recognition language. This improves accuracy but can silently "correct" uncommon proper nouns or technical terms to more common alternatives.
NEVER
- NEVER pass a remote URL or HTTP path — Vision.framework requires a local
file://URI. Remote paths produce empty output with no error raised. - NEVER treat empty output as success — Vision returns an empty string (not an exception) when: image resolution is too low, format is unsupported, or text contrast is insufficient. Always check that output is non-empty when text is expected.
- NEVER use
fastmode for Chinese-heavy images —fastdrops strokes on dense CJK characters; useaccurate(default) unless throughput is more important than accuracy. - NEVER assume pyobjc is available system-wide — this skill is a uv project. The execution wrapper (
run.ts) usesuv run --project <skillRoot>to activate or create the correct environment automatically. Never callocr-image-macos.pydirectly withpython3; always invoke vianpx tsx scripts/run.ts. - NEVER run
pip install pyobjc-*system-wide — if pyobjc is missing, runuv sync --project <skillRoot>to restore the skill environment. System-levelpip installtargets the wrong Python and won't be used byrun.ts. - NEVER run on non-macOS — the script fails fast with an explicit error; do not attempt fallback OCR (tesseract accuracy for Chinese is significantly lower).
- NEVER put
zh-Hantbeforezh-Hansin the languages list for Simplified Chinese documents — Vision uses the first language as the primary for character disambiguation; wrong ordering causes Simplified characters to be interpreted as Traditional variants, producing incorrect output on ambiguous glyphs.
Before Running — Expert Pre-flight
Before invoking OCR, ask yourself:
- Format: Is this image JPEG/PNG/HEIC/TIFF/BMP/GIF? WebP and SVG must be converted first with
sips. - Density: Is the text Chinese-heavy, handwritten, or in a dense layout? If yes →
accurateis mandatory, not optional. - Path: Is the path local and absolute (or
~/-prefixed)? HTTP paths and relative paths without context will silently fail or error. - Environment: The skill manages dependencies through uv. No manual pip install needed —
run.tsinvokesuv run --project <skillRoot>which auto-resolves dependencies. If the environment is missing or stale, runuv sync --project <skillRoot>once.
Required Constraints
- Run on macOS only — Vision.framework is not available on Linux or Windows.
- Default recognition languages:
zh-Hans,zh-Hant,en. - Default recognition level:
accurate— required for dense Chinese text;fastis ~10× faster but drops strokes on complex CJK layouts. - Input must be a local file path — Vision.framework uses a file URL internally.
Recognition Level Decision
| Scenario | Use |
|---|---|
| Chinese text, mixed scripts, handwriting, dense layouts | accurate (default) |
| English-only, printed text, speed matters more than accuracy | fast |
Supported Image Formats
Vision.framework accepts: JPEG, PNG, HEIC/HEIF, TIFF, BMP, GIF (first frame only).
Does NOT accept: WebP, SVG, raw camera formats.
If input is WebP or SVG, convert first:
sips -s format png input.webp --out input.pngAfter OCR completes, delete the converted file immediately — it is a temporary artifact. Only the original image and final bundle files should remain.
Runtime Inputs
Required: image_path — absolute or ~/-relative path to a local image file.
Optional:
output_text— path to write OCR result; stdout only if omitted.languages— comma-separated BCP-47 codes (default:zh-Hans,zh-Hant,en).recognition_level—accurate(default) orfast.
Clipsmith Bundle Normalization
The OCR runner extracts text to stdout or output_text. Before finalizing a
Clipsmith capture job, run the raw-output-to-capture.json normalization step
by creating a bundle directory containing:
ocr.mdwith the raw OCR text. This is mandatory when OCR text was produced.post.mdwith the OCR text or source metadata for consumers that expect a post-like primary file.summary.md.- The original OCR image as a separate file when it should be preserved.
capture.jsonwith schemaclipsmith.capture_bundle.v1, platformimage-ocr, the local source path,content_filesentries forsummary.md,post.md, andocr.mdwithkind: "ocr-text",assetsentries only for OCR image files with kindocr-image, warnings, and status.
Run clipsmith validate-bundle "<bundle_dir>" --json before finalizing.
Execution
cd /Users/kingsonwu/programming/OctopusGarage/clipsmith/skills/clipsmith-ocr
npx tsx scripts/run.ts \
--image_path "/path/to/image.jpg" \
[--output_text "/path/to/result.txt"] \
[--languages "zh-Hans,zh-Hant,en"] \
[--recognition_level accurate]
The wrapper invokes uv run --project <skillRoot> python scripts/ocr-image-macos.py internally. uv creates or reuses the skill environment and installs pyobjc from pyproject.toml when needed. Never call ocr-image-macos.py directly.
To use the full skill root path:
SKILL=/Users/kingsonwu/programming/OctopusGarage/clipsmith/skills/clipsmith-ocr
npx tsx "$SKILL/scripts/run.ts" --image_path "/path/to/image.jpg"
Failure Modes and Remedies
| Symptom | Likely Cause | Remedy |
|---|---|---|
| Empty output, no error | Image below ~64×64 px, wrong format, low contrast | Upscale or convert; verify format is in supported list |
Missing macOS Vision bridge dependencies | uv environment missing or stale | Run uv sync --project <skillRoot> — never pip install system-wide |
Image file not found | Path wrong or ~ not expanded | Use absolute path; script calls expanduser() automatically |
Vision request execution failed | Corrupted image file | Verify file opens in Preview; try re-exporting |
| Garbled or merged lines | Low-DPI scan or rotated image | Increase DPI or rotate to upright before OCR |
| Script fails before OCR (import error, module not found) | Called python3 directly instead of via run.ts | Always use npx tsx <skillRoot>/scripts/run.ts; or uv sync --project <skillRoot> if the uv environment is missing |
Resources
| File | Purpose |
|---|---|
references/architecture.md | Strategy layer: stage model, fallback order, quality gates, edge cases |
scripts/ocr-image-macos.py | Core OCR implementation via Vision.framework |
scripts/run.ts | Execution entry point (input parsing, delegation) |
MANDATORY — load references/architecture.md when:
- OCR returns empty output and the cause is unclear
- Input format is unsupported or needs conversion
- You need the fallback order, stage model, or known edge case handling (HEIC, GIF, PDF, rotated images)
Do NOT load references/architecture.md for standard successful runs — the information above is sufficient.
Success Criteria
A run is successful only when all conditions hold:
- Script validates runtime is macOS.
- Input image exists, is readable, and has a supported format.
- Vision request completes without API error.
- OCR text is printed to stdout (may be empty if image contains no recognizable text).
- If
output_textis provided, text file is written successfully.
What ships with it: 8 files
15.4 KB alongside SKILL.md, 2 of them executable
agents/
- openai.yaml711 B
references/
- architecture.md3.7 KB
scripts/
- ocr-image-macos.pyruns4.1 KB
- run.tsruns3.1 KB
- pyproject.toml167 B
- quality-gate.json747 B
- README.md2.3 KB
- skill.yaml679 B
Gives 0 of the 12 instructions most pdf office docs skills give in ~1.9k tokens
Counted across 636 of the 690 authors here whose files we hold, read 2026-08-07
- Extract text or tables using pdfplumber or pdftotextin 89 of 636, across 23 files
- Create new PDFs using reportlabin 83 of 636, across 16 files
- Read forms.md before filling out PDF formsin 80 of 636, across 13 files
- OCR scanned PDFs using pytesseract and pdf2imagein 77 of 636, across 10 files
- Use qpdf to merge or split PDFs or large filesin 70 of 636, across 3 files
- Use Excel formulas instead of hardcoded calculated values or Python calculationsin 68 of 636, across 13 files
- Unpack, edit, and repack XML for existing documents or presentationsin 63 of 636, across 8 files
- Document sources for all hardcoded valuesin 61 of 636, across 9 files
- Write minimal, concise Python code without unnecessary commentsin 59 of 636, across 7 files
- Run the recalculation script (recalc.py) after adding or modifying formulasin 59 of 636, across 7 files
- Fix all identified formula errors and recalculate before finishingin 58 of 636, across 6 files
- Format years as text stringsin 57 of 636, across 5 files
Said here and by no other author read
- invoke OCR via the TypeScript wrapper script
- use accurate recognition level for Chinese-heavy images
- place Simplified Chinese before Traditional in languages list
- convert WebP and SVG images before OCR
- delete temporary converted images after OCR completes
- write raw OCR text to an ocr.md bundle file
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.