SmallPict LogoSmallPict
Official Integration & SDK

Async Image Processing for FastAPI, Django, & Flask

Modern async Python client powered by httpx and Pillow fallbacks. Easily optimize media uploads in Django models, FastAPI endpoints, or background Celery / RQ workers.

Install:pip install smallpict
PYTHON Package

Implementation Example

python
# FastAPI / Async Python Example
from fastapi import FastAPI, UploadFile, File
from smallpict import AsyncSmallPictClient, ImageFormat

app = FastAPI()
client = AsyncSmallPictClient(api_key="sp_live_key_xxxxx")

@app.post("/api/upload")
async def upload_image(file: UploadFile = File(...)):
    image_bytes = await file.read()
    result = await client.optimize(
        image_bytes,
        format=ImageFormat.AVIF,
        quality=80,
        max_width=1400
    )
    return {
        "cdn_url": result.cdn_url,
        "savings": f"{result.savings_percentage}%",
        "original_size": result.original_size,
        "optimized_size": result.new_size
    }

Integration Steps

11. pip install smallpict

Install the official package from PyPI.

22. Initialize Client

Use SmallPictClient for sync apps or AsyncSmallPictClient for ASGI frameworks.

33. Plug into Upload Handlers

Wrap Django FileField or FastAPI file streams with client.optimize().

Key Benefits

  • Native asyncio support with httpx connection reuse
  • Django model field integration (SmallPictImageField)
  • Celery and RQ task decorators for batch queue execution
  • Full typing support with Pydantic schemas
Official Developer Documentation

Need Complete Implementation Guides & API Specs?

Explore parameter references, authentication mechanisms, error codes, and local testing instructions in our official Python & Django Package developer guide.

Read Python & Django Package Docs

Supercharge Your Python & Django Package Image Pipeline

Experience sub-50ms AVIF and WebP image optimization in your application. Zero setup fee, instant sandbox keys, and unlimited scalability.