skillfed

deskew

Skew detection and correction in images containing text

deskew v1.6.1 79.6K downloads/30d#14,349 on PyPI524
Permissive license MIT Active released

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 on this page — 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

deskew on PyPI

pip

pip install deskew

uv

uv add deskew

poetry

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 the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 2 — numpy, scikit-image
Maintenance actively maintained — 72 days since the last release
Last repo commit
First released
Downloads 79,574/month — #14,349 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: deskew-1.6.1-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Typing :: Typed

Tags

image skew detectiondocument deskewtext image rotation correctionangle detection imagesstraighten scanned documentsimage rotation correctionskew angle calculation
document-processingimage-analysisocr-preprocessing

More Information Analysis packages

Further reading