A high-performance, modular Python image processing library.
Project description
newlib: High-Performance Python Image Processing
newlib is a modular, production-grade image processing library designed to sit comfortably between OpenCV and modern ML frameworks. It prioritizes clean APIs, pipeline-based processing, and seamless interoperability.
🚀 Key Features
- Fluent Image API: Wrapper around NumPy arrays with method chaining (
img.resize().to_gray()). - Pipeline Engine: Lazy execution, serialization (YAML/JSON), and benchmarking.
- Machine Learning Ready:
- Seamless
to_torch()andfrom_torch()bridges. - Augmentations like
ColorJitter,RandomRotate. - ML normalization tools.
- Seamless
- Developer Friendly:
imgforgeCLI tool.- Visual debugging (
show,compare). - Built-in sample data loader (
get_sample("lenna")).
- Web-Ready IO: Automatic caching of images loaded from URLs.
📦 Installation
pip install -e .
# Optional dependencies
pip install -e .[ml] # For PyTorch/TensorFlow support
pip install -e .[dev] # For testing/development
⚡ Quick Start
Python API
from newlib.core.image import Image
from newlib.core.pipeline import Pipeline
from newlib.transforms import geometric, color, filtering
from newlib.utils.data import get_sample
# 1. Load an image (auto-downloads sample)
img = get_sample("lenna")
# 2. Method Chaining
processed = img.resize(256, 256).to_gray()
processed.save("output_fast.jpg")
# 3. Pipeline API (Recommended for reproducible workflows)
pipe = Pipeline([
geometric.Resize(224, 224),
filtering.GaussianBlur(kernel_size=5),
color.ToGray()
])
result = pipe(img)
print(f"Execution time: {pipe.benchmark()}")
CLI Tool (imgforge)
Resize an image:
imgforge resize input.jpg 512 512 output.jpg
Inspect image metadata & quality:
imgforge inspect https://example.com/image.jpg
Run a Pipeline from YAML:
# pipeline.yaml
pipeline:
- name: Resize
params:
width: 256
height: 256
- name: ToGray
imgforge pipeline pipeline.yaml input.jpg output.jpg
🛠️ Modules Overview
| Module | Description | Key Classes/Functions |
|---|---|---|
core |
Foundations | Image, Pipeline, IO, interop |
transforms |
Image manipulation | Resize, Rotate, Crop, ToGray, GaussianBlur |
vision |
Computer Vision | Canny, Sobel, find_contours, ORB, FAST |
analysis |
Metrics & Stats | inspect, get_stats, estimate_blur, mse, psnr |
utils |
Developer Tools | show, compare, get_sample |
🤝 ML Integration
Stop fighting with NumPy/Tensor conversions.
from newlib.core.interop import to_torch
img = Image.open("dataset/001.jpg")
# Automatically converts to (C, H, W) float tensor
tensor = to_torch(img.data, device="cuda")
🧪 Running Tests
python -m pytest tests/
📄 License
MIT License. See LICENSE for details.
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 imgforge-0.1.1.tar.gz.
File metadata
- Download URL: imgforge-0.1.1.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c69f822848ee5dfd1b851869bf60faaf2275bbe138db50d0a1c76e54abcddeed
|
|
| MD5 |
924365173f091f22c7e47455d95fbabe
|
|
| BLAKE2b-256 |
28540f0ad0234eacdac512e24fac7fadb8e6cad81d487c7ed9069aa38d1cc0be
|
File details
Details for the file imgforge-0.1.1-py3-none-any.whl.
File metadata
- Download URL: imgforge-0.1.1-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de14ccdc0ac4a357a3d9fa9b5e582e844fc7f3d1a777b82c10096d2d7a90d145
|
|
| MD5 |
861ba581a8bc29a4abfd9e5ec9bf1681
|
|
| BLAKE2b-256 |
95b68be798942c0fa61ec524372ed1f2721190cdc828be030e616538849d81ec
|