When to Use
Use when the user wants to scan a document from a photo, crop the page automatically, fix perspective, or make an image look like it came from a flatbed scanner.
Load this skill when the request sounds like:
- - "scan this document"
- "crop the page edges"
- "make this photo look scanned"
- "deskew this paper"
- "clean up this receipt or sheet"
Default Engine
Default to jscanify.
Why this is the default:
- - Open source and MIT licensed
- Mature enough to trust for general use
- Works in browser, CDN, npm, and Node-oriented workflows
- Uses OpenCV.js without forcing a native OpenCV install
- Lower friction than mobile-native or commercial SDKs
Do not default to commercial SDKs unless the user explicitly asks for a production mobile SDK or already uses one in their app.
Quick Workflow
- 1. Start with
jscanify, not custom image math. - Detect the page boundary first.
- Extract with perspective correction.
- Review the output visually.
- If edges are wrong, stop and retry with a cleaner input or a manual-corner flow instead of stacking random filters.
Basic Commands
1. Project install
CODEBLOCK0
2. Zero-global-install local preview
Use CDN scripts in a tiny HTML page and serve it locally:
CODEBLOCK1
Load:
CODEBLOCK2
3. Core extraction
CODEBLOCK3
4. Edge preview before crop
CODEBLOCK4
Core Rules
1. Browser-first wins
- - Prefer the browser or browser-like path first because
jscanify is strongest there. - Prefer CDN or local project dependency over native OpenCV builds.
- If the user only needs one scan, choose the lowest-friction path.
2. Detect before you "enhance"
- - First run boundary detection on the original image.
- Only add grayscale, contrast, or thresholding after edge detection fails.
- Do not overprocess before trying the default extraction path.
3. Expect flat, visible borders
- - Best results come from one document on a contrasting background.
- Top-down or near-top-down photos are safer than steep angles.
- Hard shadows, fingers over corners, or white paper on white tables reduce reliability.
4. Preserve the original
- - Never overwrite the only copy of the input image.
- Save the corrected export separately.
- If the scan is for legal, accounting, or archive use, keep the original photo too.
5. Manual correction beats fake certainty
- - If auto-detection is clearly wrong, do not pretend it succeeded.
- Ask for a better photo or switch to a manual-corner workflow.
- Wrong corners produce worse output than no crop.
Common Traps
- - Busy backgrounds can confuse edge detection.
- Low contrast document-on-table shots fail more often than users expect.
- Glare can hide one full edge and make the crop collapse.
- Very curved paper is not a normal document-scan case.
- Receipts with torn edges or shadows often need one retry with a better photo.
- OCR and document scanning are different jobs; scan first, OCR second.
Scope
This skill ONLY:
- - Chooses and applies a document-scanning workflow
- Prioritizes
jscanify by default - Produces cropped, perspective-corrected scan-style images
This skill NEVER:
- - Claims OCR accuracy improvements by itself
- Recommends paid SDKs by default
- Reimplements document detection from scratch unless the user explicitly wants that
External Endpoints
| Endpoint | Purpose |
|---|
| INLINECODE4 | Load OpenCV.js in browser-first workflows |
| INLINECODE5 |
Load
jscanify without global install |
Related Skills
Install with
clawhub install <slug> if user confirms:
- -
documents - General document handling after the scan is cleaned. - INLINECODE9 - Extra image cleanup when the user needs post-processing beyond edge detection.
- INLINECODE10 - File organization, renaming, and export handling after scans are generated.
Feedback
- - If useful: INLINECODE11
- Stay updated: INLINECODE12
使用场景
当用户想要从照片中扫描文档、自动裁剪页面、修正透视,或让图像看起来像是来自平板扫描仪时使用。
当请求听起来像这样时加载此技能:
- - 扫描这份文档
- 裁剪页面边缘
- 让这张照片看起来像扫描件
- 校正这张纸的倾斜
- 清理这张收据或纸张
默认引擎
默认使用 jscanify。
选择此默认引擎的原因:
- - 开源且采用MIT许可证
- 足够成熟,可放心用于常规用途
- 适用于浏览器、CDN、npm和Node相关的工作流程
- 使用OpenCV.js,无需强制安装原生OpenCV
- 比移动原生或商业SDK的摩擦更小
除非用户明确要求生产级移动SDK或已在应用中使用,否则不要默认使用商业SDK。
快速工作流程
- 1. 从 jscanify 开始,而不是自定义图像数学运算。
- 首先检测页面边界。
- 使用透视校正进行提取。
- 视觉检查输出结果。
- 如果边缘错误,停止并使用更清晰的输入或手动角点流程重试,而不是堆叠随机滤镜。
基本命令
1. 项目安装
bash
npm install jscanify
2. 零全局安装本地预览
在小型HTML页面中使用CDN脚本并在本地提供服务:
bash
npx serve .
加载:
html
3. 核心提取
js
const scanner = new jscanify();
const resultCanvas = scanner.extractPaper(image, 1600, 2200);
4. 裁剪前边缘预览
js
const scanner = new jscanify();
const highlightedCanvas = scanner.highlightPaper(image);
核心规则
1. 浏览器优先
- - 优先选择浏览器或类似浏览器的路径,因为 jscanify 在此环境中最强。
- 优先使用CDN或本地项目依赖,而非原生OpenCV构建。
- 如果用户只需要一次扫描,选择摩擦最小的路径。
2. 先检测再增强
- - 首先对原始图像运行边界检测。
- 仅在边缘检测失败后添加灰度、对比度或阈值处理。
- 在尝试默认提取路径之前不要过度处理。
3. 预期平坦、可见的边界
- - 最佳结果来自对比背景上的单个文档。
- 俯视或接近俯视的照片比大角度照片更可靠。
- 硬阴影、手指遮挡角点或白纸放在白桌上会降低可靠性。
4. 保留原始文件
- - 切勿覆盖输入图像的唯一副本。
- 单独保存校正后的导出文件。
- 如果扫描用于法律、会计或存档用途,也要保留原始照片。
5. 手动修正优于虚假确定
- - 如果自动检测明显错误,不要假装成功。
- 要求提供更好的照片或切换到手动角点工作流程。
- 错误的角点产生的输出比不裁剪更差。
常见陷阱
- - 复杂的背景可能会混淆边缘检测。
- 低对比度的文档放在桌上的照片比用户预期的更容易失败。
- 眩光可能隐藏一整条边缘,导致裁剪失败。
- 严重弯曲的纸张不属于正常的文档扫描情况。
- 边缘撕裂或有阴影的收据通常需要用更好的照片重试一次。
- OCR和文档扫描是不同的工作;先扫描,后OCR。
范围
此技能仅:
- - 选择并应用文档扫描工作流程
- 默认优先使用 jscanify
- 生成裁剪、透视校正的扫描风格图像
此技能绝不:
- - 声称自身能提高OCR准确性
- 默认推荐付费SDK
- 从头重新实现文档检测,除非用户明确要求
外部端点
| 端点 | 用途 |
|---|
| https://docs.opencv.org/ | 在浏览器优先工作流程中加载OpenCV.js |
| https://cdn.jsdelivr.net/ |
无需全局安装即可加载 jscanify |
相关技能
如果用户确认,使用 clawhub install
安装:
- - documents - 扫描清理后的常规文档处理。
- image - 当用户需要边缘检测之外的后期处理时进行额外的图像清理。
- files - 扫描生成后的文件组织、重命名和导出处理。
反馈
- - 如果觉得有用:clawhub star scanner
- 保持更新:clawhub sync