Naar inhoud springen
smallPict
Gratis Starten
HomeIntegratiesPython & Django Pakket

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

PYTHON Pakket
$ pip install smallpict

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

  1. Installeer via Pip

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

  2. Definieer Instellingen

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

  3. Verwerk 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

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

Versnel uw Python & Django Pakket-beeldpipeline

Probeer AVIF- en WebP-beeldoptimalisatie in uw applicatie. Geen installatiekosten en direct sandbox-sleutels.