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.
Metadata
Release files for imgforge 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| imgforge-0.1.1.tar.gz | 18.3 kB | Without provenance | Details for imgforge-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| imgforge-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for imgforge-0.1.1-py3-none-any.whl |
Total release size: 41.0 kB
Release files / imgforge-0.1.1.tar.gz
| Download URL | imgforge-0.1.1.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c69f822848ee5dfd1b851869bf60faaf2275bbe138db50d0a1c76e54abcddeed
|
|
BLAKE2b-256 checksum How to use checksums |
28540f0ad0234eacdac512e24fac7fadb8e6cad81d487c7ed9069aa38d1cc0be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Release files / imgforge-0.1.1-py3-none-any.whl
| Download URL | imgforge-0.1.1-py3-none-any.whl |
|---|---|
| Size | 22.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de14ccdc0ac4a357a3d9fa9b5e582e844fc7f3d1a777b82c10096d2d7a90d145
|
|
BLAKE2b-256 checksum How to use checksums |
95b68be798942c0fa61ec524372ed1f2721190cdc828be030e616538849d81ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Security for imgforge 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.