Skip to main content

A modern, high-performance image processing library for Python, powered by Rust.

Project description

Puhu 🦉

CI Python Rust License

A blazingly fast, modern image processing library for Python, powered by Rust. Puhu provides a Pillow-compatible API while delivering significantly performance for common image operations.

✨ Key Features

  • 🔥 High Performance: Significantly fast for common image operations
  • 🔄 Pillow Compatible: Drop-in replacement for most Pillow operations
  • 🦀 Rust Powered: Memory-safe and efficient core written in Rust
  • 📦 Easy to Use: Simple, intuitive API that feels familiar
  • 🎯 Format Support: PNG, JPEG, BMP, TIFF, GIF, WEBP

🚀 Quick Start

Installation

pip install puhu

Basic Usage

import puhu

# Open an image
img = puhu.open("photo.jpg")

# Resize image
resized = img.resize((800, 600))

# Crop image
cropped = img.crop((100, 100, 500, 400))

# Rotate image
rotated = img.rotate(90)

# Save image
img.save("output.png")

# Create new image
new_img = puhu.new("RGB", (800, 600), "red")

Drop-in Pillow Replacement

# Replace this:
# from PIL import Image

# With this:
from puhu import Image

# Your existing Pillow code works unchanged!
img = Image.open("photo.jpg")
img = img.resize((400, 300))
img.save("resized.jpg")

🔄 Pillow Compatibility

✅ Fully Compatible Operations

  • open(), new(), save()
  • resize(), crop(), rotate(), transpose()
  • copy(), thumbnail()
  • Properties: size, width, height, mode, format
  • All major image formats (PNG, JPEG, BMP, TIFF, GIF, WEBP)

🚧 Planned Features

  • convert(), paste(), split() - High Priority
  • filter(), getpixel(), putpixel() - Medium Priority
  • fromarray(), frombytes() - NumPy Integration

📖 API Reference

Core Functions

# Open image from file or bytes
img = puhu.open("path/to/image.jpg")
img = puhu.open(image_bytes)

# Create new image
img = puhu.new(mode, size, color=None)
# Examples:
img = puhu.new("RGB", (800, 600))  # Black image
img = puhu.new("RGB", (800, 600), "red")  # Red image
img = puhu.new("RGB", (800, 600), (255, 0, 0))  # Red image with RGB tuple

Image Operations

# Resize image
resized = img.resize((width, height), resample=puhu.Resampling.BILINEAR)

# Crop image (left, top, right, bottom)
cropped = img.crop((x1, y1, x2, y2))

# Rotate image (90°, 180°, 270° supported)
rotated = img.rotate(90)

# Transpose/flip image
flipped = img.transpose(puhu.Transpose.FLIP_LEFT_RIGHT)
flipped = img.transpose(puhu.Transpose.FLIP_TOP_BOTTOM)

# Copy image
copy = img.copy()

# Create thumbnail (modifies image in-place)
img.thumbnail((200, 200))

# Save image
img.save("output.jpg", format="JPEG")
img.save("output.png")  # Format auto-detected from extension

Properties

# Image dimensions
width = img.width
height = img.height
size = img.size  # (width, height) tuple

# Image mode and format
mode = img.mode  # "RGB", "RGBA", "L", etc.
format = img.format  # "JPEG", "PNG", etc.

# Raw pixel data
bytes_data = img.to_bytes()

🔧 Development

Building from Source

# Clone repository
git clone https://github.com/your-username/puhu.git
cd puhu

# Install dependencies
pip install -r requirements.txt

# Build Rust extension
maturin develop --release

# Run tests
pytest python/puhu/tests/

Requirements

  • Python 3.8+
  • Rust 1.70+
  • Maturin for building

🤝 Contributing

Contributions are welcome! Areas where help is needed:

  1. High Priority Features: convert(), paste(), fromarray(), split()
  2. Performance Optimization: Further speed improvements
  3. Format Support: Additional image formats
  4. Documentation: Examples and tutorials
  5. Testing: Edge cases and compatibility tests

📄 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments

  • Built with PyO3 for Python-Rust integration
  • Uses image-rs for core image processing
  • Inspired by Pillow for API design

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

puhu-0.2.0.tar.gz (71.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

puhu-0.2.0-cp38-abi3-win_amd64.whl (758.1 kB view details)

Uploaded CPython 3.8+Windows x86-64

puhu-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (936.1 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

puhu-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (897.8 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

puhu-0.2.0-cp38-abi3-macosx_11_0_arm64.whl (755.2 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

puhu-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl (885.6 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file puhu-0.2.0.tar.gz.

File metadata

  • Download URL: puhu-0.2.0.tar.gz
  • Upload date:
  • Size: 71.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.6

File hashes

Hashes for puhu-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a8b1fa6ab0726bc3c1ae6fb43fca8535dcdcda2e0180f02cedf9b5607e5a83c8
MD5 494c68d7ed817ad33e32e2abdc9e0457
BLAKE2b-256 5f89d4ff79d5ca15e9cb31dcdab8c5c375f0bf056616e5e900c5541b1e6b18c9

See more details on using hashes here.

File details

Details for the file puhu-0.2.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: puhu-0.2.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 758.1 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.6

File hashes

Hashes for puhu-0.2.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b3d711c802548bd9e94437b96813fe5d9632ffbf3553245b24579312a0036996
MD5 bbfb1161f80195139fb20ee2d160b4b9
BLAKE2b-256 6d815e818007e6c637943e04eabdd01cd26c811e0b89ea1ad7edcde08a99c45a

See more details on using hashes here.

File details

Details for the file puhu-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for puhu-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a49cbcdfa96b4ce793f25d0cba04184d402484de4839de52ab029accb5b7852b
MD5 90d1076379789580e1fd0dc049a8296d
BLAKE2b-256 4ab72a71079e26310f4cec8a852136fe7a3ff0b23667c2e1396302c9247e86d6

See more details on using hashes here.

File details

Details for the file puhu-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for puhu-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a9ec68dea09b27c30c6cddbe5dd78c70330621b7f6b8a4d3e274b9744ee3ccc2
MD5 25630e49d46d67f5f42ca54887eb7a98
BLAKE2b-256 60961ff04f405b1383d4516971e07da7b61b254b441d725c78a0548ad89771d1

See more details on using hashes here.

File details

Details for the file puhu-0.2.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for puhu-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c5df32976fef37b5a3b2e94c632532a1aee64d957eefc3a9c6ec0c1b2a9925b
MD5 3f655c9fb5f3fe64eef5cbf0b41151bc
BLAKE2b-256 045db126787fe4f423b8ab652a892267e60461c013211ff1a11d477d868535c1

See more details on using hashes here.

File details

Details for the file puhu-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for puhu-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 140ca2f66fb1f93a0c25166436e1df7e9fb427e30a43f7106e665dc4a5bc6b8c
MD5 eea79c4f9dbfb931ec359373bd980ea1
BLAKE2b-256 0bcad11fbe307acb9b56045164eb188e5e8a58a63e26a70f5c496a2053898342

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page