Skip to main content

Detect and fix orientation of images using deep learning

Project description

orient

Detect and fix image orientation using a deep learning model (Deep-OAD ViT).

Install

pip install orient

Usage

import orient

# Detect orientation
result = orient.detect("photo.jpg")
result.orientation      # orient.Orientation.CW_90
result.confidence       # 0.93
result.angle            # 82.4
result.needs_rotation   # True
result.is_correct       # False

# Batch detection
results = orient.detect(["a.jpg", "b.jpg"])

# Folder detection — finds all JPEGs recursively
results = orient.detect("photos/")
for r in results:
    print(f"{r.path.name}: {r.orientation.label}")

# Folder options
orient.detect("photos/", batch_size=16, recursive=False)

# PIL Image input
from PIL import Image
result = orient.detect(Image.open("photo.jpg"))

# Detect + fix orientation
orient.fix("photo.jpg")                       # set EXIF tag (default, lossless)
orient.fix("photo.jpg", method="transpose")   # rotate pixels via Pillow
orient.fix(["a.jpg", "b.jpg"])

# Fix an entire folder
orient.fix("photos/")

How it works

Uses a fine-tuned ViT model to predict the rotation angle of an image. For 90/270 degree predictions, a verification pass rotates the image both ways and picks the direction that looks most upright.

Model weights (~990 MB) are automatically downloaded from Hugging Face on first use.

Rotation methods

  • exif (default) — Sets the EXIF Orientation tag via piexif. Truly lossless (metadata only). No external tools needed.
  • transpose — Rotates pixels using Pillow. Re-encodes JPEG but works everywhere. No external tools needed.

See also

  • auto-orient - CLI tool for bulk processing
  • Deep-OAD - The underlying orientation angle detection model

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orient_img-0.2.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orient_img-0.2.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file orient_img-0.2.0.tar.gz.

File metadata

  • Download URL: orient_img-0.2.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for orient_img-0.2.0.tar.gz
Algorithm Hash digest
SHA256 46a11b5435b0e721b53efbb1f80023a265d8aefd34dd5b4e925751d7f62498e1
MD5 2ae97213351fe5c7ed675fbc462f11b1
BLAKE2b-256 15d2103d0275e9070501ffd9c42b5a6d11ea29372c1697ef865f8e1f44d1ea84

See more details on using hashes here.

Provenance

The following attestation bundles were made for orient_img-0.2.0.tar.gz:

Publisher: publish.yml on FocalChord/orient

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file orient_img-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: orient_img-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for orient_img-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ccdef866ffb6d191156d6902ec073ae635498be62ea969ed061ddfa7e3aabefe
MD5 0a79ed7c84204f7d095f51e6cefec7ba
BLAKE2b-256 8695d042d9ddfa7be28424efb5dd322baab6f4172abccefb83e9d2ea40a66f8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for orient_img-0.2.0-py3-none-any.whl:

Publisher: publish.yml on FocalChord/orient

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page