auto-deskew
Installation
SKILL.md
Auto Deskew
Straighten a tilted image. Two backends, picked by content type:
- document (default) —
magick -deskew 40%. Detects skew via the Radon-style projection profile that ImageMagick's deskew operator implements. Fast, robust on text/scans up to ±15°. - photo — Python + OpenCV Hough-line transform. Detects the dominant horizontal/vertical line angle (horizons, building edges, table corners) and rotates by its negative. Use for photographs without a clean text baseline.
When to use
- Scanned documents that came in at an angle.
- Phone snapshots of pages, receipts, whiteboards.
- Slightly-tilted architectural / horizon photos (
--mode photo). - Pre-step before OCR — Tesseract accuracy degrades sharply past ±2° skew.
Do not use this skill when:
- The image is intentionally tilted (Dutch angle, artistic composition).
- Skew is severe (>15°) — usually means the document was captured upside down or sideways. Detect orientation first (
exiftool -Orientation, or rotate by 90/180 multiples) before deskewing. - The image has no straight reference lines (clouds, abstract textures) — Hough will return noise; rotation will be near-random.