--- id: deskew version: "1.6.1" license: MIT license_treatment: permissive maintenance: active --- # deskew — Skew detection and correction in images containing text License: permissive · Maintenance: active · Downloads: 79.6K/mo ## What it is and what it does Deskew is a Python library that detects and corrects image skew—the rotation angle of text or documents in images. It analyzes grayscale images to determine the rotation angle (between -45 and 45 degrees by default, or -90 to 90 with the `angle_pm_90` option) and returns that angle for use in downstream rotation. The library works with both scikit-image and OpenCV workflows, accepting numpy arrays and integrating into standard image processing pipelines. The package is designed for document scanning, OCR preprocessing, and text image normalization. It depends on numpy for numerical operations and scikit-image for image manipulation, making it lightweight and suitable for batch processing. A CLI tool is also provided for quick angle detection or direct deskewing of image files, and optional debug output is available to tune detection parameters when results are suboptimal. Use it for: - Preprocess scanned documents for OCR by detecting and reporting their rotation angle - Straighten photographs of text-heavy documents before feeding to text recognition systems - Batch-correct skewed images in document digitization pipelines - Detect rotation angle in document images without rotating, for logging or analysis - Integrate skew correction into image processing workflows using scikit-image or OpenCV ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Detects and corrects image skew (rotation) in documents and text-containing images by calculating the rotation angle and providing tools to straighten them. Yes. Deskew solves a specific, well-defined problem (skew detection in text images) with low install friction, active maintenance, no known vulnerabilities, and a permissive MIT license. It is suitable for document processing and OCR preprocessing workflows. Install it if you need to detect or correct image rotation in text-heavy documents. ## Install pip install deskew uv add deskew poetry add deskew ## Installing deskew Before you install: Low friction: pure Python wheel with only numpy and scikit-image as runtime dependencies. Active maintenance with recent release (72 days ago) and 524 repository stars. License in practice: MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal attribution requirements. Quickstart: pip install deskew from deskew import determine_skew import numpy as np from skimage import io from skimage.color import rgb2gray from skimage.transform import rotate image = io.imread('input.png') grayscale = rgb2gray(image) angle = determine_skew(grayscale) rotated = rotate(image, angle, resize=True) * 255 io.imsave('output.png', rotated.astype(np.uint8)) Requires Python 3.11 or later Verify before relying: - Accuracy of skew detection across different document types, resolutions, and languages - Performance characteristics on large batches or high-resolution images - Whether the debug_images extra dependency set is necessary for typical use cases ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 79.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags image skew detection, document deskew, text image rotation correction, angle detection images, straighten scanned documents, image rotation correction, skew angle calculation, document-processing, image-analysis, ocr-preprocessing [View on SkillFed](https://skillfed.io/packages/deskew) · [View on PyPI](https://pypi.org/project/deskew/)