Metadata-Version: 2.4
Name: pyimagekit
Version: 0.1.0a2
Summary: A Python library that provides a unified interface for handling images across multiple formats and performing common image processing tasks.
Project-URL: Repository, https://github.com/Hoopoes/pyimagekit
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: numpy>=1.21.6
Requires-Dist: opencv-python-headless>=4.13.0.92
Requires-Dist: pillow>=9.5.0
Requires-Dist: pydantic>=2.5.3
Provides-Extra: all
Requires-Dist: pytesseract; extra == 'all'
Provides-Extra: pytesseract
Requires-Dist: pytesseract>=0.3.13; extra == 'pytesseract'
Description-Content-Type: text/markdown

# 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

```bash
pip install pyimagekit
```

To include OCR support for document uprighting, install with the optional dependency:

```bash
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.

```python
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