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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46a11b5435b0e721b53efbb1f80023a265d8aefd34dd5b4e925751d7f62498e1
|
|
| MD5 |
2ae97213351fe5c7ed675fbc462f11b1
|
|
| BLAKE2b-256 |
15d2103d0275e9070501ffd9c42b5a6d11ea29372c1697ef865f8e1f44d1ea84
|
Provenance
The following attestation bundles were made for orient_img-0.2.0.tar.gz:
Publisher:
publish.yml on FocalChord/orient
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orient_img-0.2.0.tar.gz -
Subject digest:
46a11b5435b0e721b53efbb1f80023a265d8aefd34dd5b4e925751d7f62498e1 - Sigstore transparency entry: 1008546302
- Sigstore integration time:
-
Permalink:
FocalChord/orient@31951c5bc3b660ca8ca330879b3cbc6ea9cc52c3 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/FocalChord
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@31951c5bc3b660ca8ca330879b3cbc6ea9cc52c3 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccdef866ffb6d191156d6902ec073ae635498be62ea969ed061ddfa7e3aabefe
|
|
| MD5 |
0a79ed7c84204f7d095f51e6cefec7ba
|
|
| BLAKE2b-256 |
8695d042d9ddfa7be28424efb5dd322baab6f4172abccefb83e9d2ea40a66f8a
|
Provenance
The following attestation bundles were made for orient_img-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on FocalChord/orient
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orient_img-0.2.0-py3-none-any.whl -
Subject digest:
ccdef866ffb6d191156d6902ec073ae635498be62ea969ed061ddfa7e3aabefe - Sigstore transparency entry: 1008546305
- Sigstore integration time:
-
Permalink:
FocalChord/orient@31951c5bc3b660ca8ca330879b3cbc6ea9cc52c3 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/FocalChord
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@31951c5bc3b660ca8ca330879b3cbc6ea9cc52c3 -
Trigger Event:
release
-
Statement type: