A Python library that provides a unified interface for handling images across multiple formats and performing common image processing tasks.
Project description
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
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 pyimagekit-0.1.0a2.tar.gz.
File metadata
- Download URL: pyimagekit-0.1.0a2.tar.gz
- Upload date:
- Size: 68.6 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4140ff7d29f0d0c2e12ca93f0c5b4a72ae4d6c516d10cb28d9777365de17d4be
|
|
| MD5 |
cfbbf6b73cbc7eaf304ac075aef58f14
|
|
| BLAKE2b-256 |
5bdfa728563cf2a71bdb9d3a04991eb910cab0ff59bfa0b8431b8a0c8c78d576
|
File details
Details for the file pyimagekit-0.1.0a2-py3-none-any.whl.
File metadata
- Download URL: pyimagekit-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abdafd780b693991b75dca1bcfe7b25e356426d2d70098971f0b4479c7104158
|
|
| MD5 |
083563d0c43806c7359abfcf6e667be2
|
|
| BLAKE2b-256 |
eb3d3605c42314744679d4a9ebab6b934e4117dbbb1563d4c4f592feab5c69f2
|