SmallPict LogoSmallPict
Officiƫle Integratie & SDK

Elegante integratie voor Django, FastAPI en Machine Learning-pijplijnen

Optimaliseer en transformeer afbeeldingen in Python via asynchrone httpx-interfaces of via aangepaste Django ImageField-opslagbackends.

Installeren:pip install smallpict
PYTHON Pakket

Implementatievoorbeeld

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
    }

Integratiestappen

1Installeer via Pip

Voer pip install smallpict uit in uw virtuele Python-omgeving.

2Definieer Instellingen

Stel SMALLPICT_API_KEY in via uw omgevingsvariabelen of in settings.py van Django.

3Verwerk Afbeeldingen

Gebruik de asynchrone client in FastAPI of het opslagbackend in Django.

Belangrijkste Voordelen

  • Native asynchrone ondersteuning met async/await voor FastAPI en Starlette
  • Aangepast opslagbackend voor Django met automatische miniatuuraanmaak
  • Volledig compatibel met Pillow en NumPy-matrices voor computer vision
  • Automatische herhaalpogingen met exponentiĆ«le vertraging bij netwerkstoringen
Officiƫle Ontwikkelaarsdocumentatie

Complete handleidingen en API-specificaties nodig?

Ontdek parameterreferenties, authenticatie en lokaal testen in onze officiƫle Python & Django Pakket-handleiding.

Lees Python & Django Pakket Documentatie

Geef je Python & Django Pakket Beeld-pipeline een Boost

Ervaar AVIF- en WebP-optimalisatie in minder dan 50 ms. Geen installatiekosten, directe sandbox-sleutels.