This release is a pre-release and may not be stable for production use.
PyImageKit
A Python library providing a unified interface for handling images across multiple formats (bytes, OpenCV cv2, Pillow Image) and performing common image processing tasks.
Installation
pip install pyimagekit
To include OCR support for document uprighting, install with the optional dependency:
pip install "pyimagekit[pytesseract]"
Quick Start
pyimagekit centers around the SmartImage class, which allows you to seamlessly load, transform, and export images. It implements a fluent interface so operations can be chained.
from pyimagekit import SmartImage
# 1. Load an image
with open("document.jpg", "rb") as f:
img = SmartImage.from_bytes(f.read())
# Alternatively:
# img = SmartImage.from_cv2(cv2_image)
# img = SmartImage.from_pillow(pil_image)
# 2. Process the image
processed_img = (
img.resize(width=800)
.rotate(90)
.ensure_document_portrait()
)
# 3. Export the processed image
jpeg_bytes = processed_img.to_bytes(format="JPEG", quality=85)
base64_str = processed_img.to_base64(format="PNG")
cv2_mat = processed_img.to_cv2()
pillow_img = processed_img.to_pillow()
Features
The SmartImage class currently supports the following operations:
- Loading:
from_bytes,from_cv2,from_pillow - Exporting:
to_cv2,to_pillow,to_bytes,to_base64 - Transformations:
resize,crop,rotate,sharpen_v1,sharpen_v2,adjust_quality,apply(for custom functions) - Document Processing:
unwarp_document,ensure_document_upright,ensure_document_portrait,ensure_document_landscape
License
MIT License
Release files for pyimagekit 0.1.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyimagekit-0.1.0a2.tar.gz | 68.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyimagekit-0.1.0a2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 75.6 kB
Release files / pyimagekit-0.1.0a2.tar.gz
| Download URL | pyimagekit-0.1.0a2.tar.gz |
|---|---|
| Size | 68.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4140ff7d29f0d0c2e12ca93f0c5b4a72ae4d6c516d10cb28d9777365de17d4be
|
|
BLAKE2b-256 checksum How to use checksums |
5bdfa728563cf2a71bdb9d3a04991eb910cab0ff59bfa0b8431b8a0c8c78d576
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyimagekit-0.1.0a2-py3-none-any.whl
| Download URL | pyimagekit-0.1.0a2-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
abdafd780b693991b75dca1bcfe7b25e356426d2d70098971f0b4479c7104158
|
|
BLAKE2b-256 checksum How to use checksums |
eb3d3605c42314744679d4a9ebab6b934e4117dbbb1563d4c4f592feab5c69f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|