imgrs

Blazing Fast Image Processing for Python, Powered by Rust

196x Faster I/O Memory Safe Pillow Compatible
Get Started

Why Choose imgrs?

Blazing Fast

196x faster image loading, 8.5x faster saving. Rust-powered performance without the complexity.

Memory Safe

Built with Rust's memory safety guarantees. No segfaults, no memory leaks, just reliable performance.

Pillow Compatible

Familiar API. Most Pillow code works with minimal changes. Easy migration path.

Cross-Platform

Pre-built wheels for Linux, Windows, macOS, and Android. No compilation needed!

SIMD Optimized

Vectorized operations using AVX2/SSE4. Maximum performance from modern CPUs.

Type Safe

Full type hints for IDE autocomplete. Catch errors before runtime with mypy support.

Installation

pip install imgrs

Supports Python 3.8-3.12 on Linux, Windows, macOS, and Android

Quick Start

Open and Resize

from imgrs import Image

# Open image (196x faster than Pillow!)
img = Image.open("photo.jpg")

# Resize (1.5x faster than Pillow!)
resized = img.resize((800, 600))

# Save (8.5x faster than Pillow!)
resized.save("output.png")

Apply Filters

from imgrs import Image

img = Image.open("photo.jpg")

# Chain filters
result = (img
    .blur(5.0)
    .brightness(10)
    .contrast(1.2)
    .sharpen(1.5))

result.save("enhanced.jpg")

Draw Shapes

from imgrs import Image

# Create canvas
img = Image.new("RGB", (400, 300), (255, 255, 255))

# Draw shapes
img = img.draw_rectangle(50, 50, 100, 100, (255, 0, 0, 255))
img = img.draw_circle(200, 150, 50, (0, 255, 0, 255))

img.save("shapes.png")

Add Effects

from imgrs import Image

img = Image.open("logo.png")

# Add drop shadow
shadowed = img.drop_shadow(
    offset_x=10,
    offset_y=10,
    blur_radius=15.0,
    shadow_color=(0, 0, 0, 128)
)

shadowed.save("logo_shadow.png")

Performance Benchmarks

Operation Pillow imgrs Winner
Open Image 0.49ms 0.00ms imgrs 196x ⚡
Save PNG 134.11ms 15.75ms imgrs 8.5x ⚡
Resize 16.33ms 10.59ms imgrs 1.5x ⚡
Convert Grayscale 3.06ms 5.10ms Pillow 1.7x
Rotate 90° 4.83ms 9.11ms Pillow 1.9x

View Full Benchmark Results

196x

Faster Image Opening

8.5x

Faster Image Saving

23x

Average Speedup

Comprehensive Feature Set

Image Operations
  • Resize with quality options
  • Crop and rotate
  • Flip and transpose
  • Convert between modes (RGB, RGBA, L, LA)
  • Split and merge channels
Filters & Effects
  • Blur, sharpen, edge detection
  • Brightness, contrast adjustments
  • CSS-like filters (sepia, grayscale, hue)
  • Drop shadows and glows
  • Posterize and threshold
Drawing Tools
  • Draw rectangles and circles
  • Draw lines (Bresenham's algorithm)
  • Render text with built-in font
  • Alpha blending support
  • Custom colors with transparency
Pixel Manipulation
  • Get and set individual pixels
  • Color analysis (dominant, average)
  • Histogram generation
  • Replace colors with tolerance
  • NumPy array support

Code Examples

Thumbnail Generation
from imgrs import Image
from pathlib import Path

def create_thumbnails(input_dir, size=(150, 150)):
    for img_path in Path(input_dir).glob("*.jpg"):
        img = Image.open(img_path)
        thumb = img.resize(size, resample="LANCZOS")
        thumb.save(f"thumbs/{img_path.name}")

create_thumbnails("photos/")
Photo Enhancement
from imgrs import Image

def enhance_photo(img):
    return (img
        .resize((1920, 1080), resample="LANCZOS")
        .brightness(10)
        .contrast(1.2)
        .saturate(1.1)
        .sharpen(1.5))

img = Image.open("photo.jpg")
enhanced = enhance_photo(img)
enhanced.save("enhanced.jpg")
Add Watermark
from imgrs import Image

img = Image.open("photo.jpg")

# Semi-transparent watermark
watermark = (255, 255, 255, 128)
img = img.draw_text(
    "© 2025",
    10, 
    img.height - 30,
    watermark,
    scale=2
)

img.save("watermarked.jpg")
Batch Processing
from imgrs import Image
from pathlib import Path

# Convert all JPEGs to WebP
for jpg in Path("photos/").glob("*.jpg"):
    img = Image.open(jpg)
    # Resize if too large
    if img.width > 1920:
        img = img.resize((1920, 1080))
    
    webp = jpg.with_suffix(".webp")
    img.save(webp, format="WEBP")
    print(f"✅ {webp.name}")

Documentation

API Reference

Complete API documentation

Read Docs
Quick Start

Get started in 5 minutes

Get Started
Examples

Ready-to-use code examples

View Examples
Migration

From Pillow to imgrs

Migration Guide

Platform Support

Linux
manylinux wheels
Windows
x64, x86, ARM64
macOS
Intel & Apple Silicon
Android
ARM & x86