This page was machine-translated. Spotted a mistake?Help improve it.
Skip to content

Hintergrund entfernen

KI-gestützte Hintergrundentfernung mit optionalen Effekten (Weichzeichnen, Schatten, Verlauf, eigener Hintergrund).

API-Endpunkt

POST /api/v1/tools/image/remove-background

Verarbeitung: Asynchron (gibt 202 zurück, Status über SSE per /api/v1/jobs/{jobId}/progress abfragen)

Modell-Bundle: background-removal (4-5 GB)

Parameter

ParameterTypErforderlichStandardBeschreibung
filefileJa-Bilddatei (multipart)
modelstringNein-Zu verwendende KI-Modellvariante
backgroundTypestringNein"transparent"Eines von: transparent, color, gradient, blur, image
backgroundColorstringNein-Hex-Farbe für einfarbigen Hintergrund
gradientColor1stringNein-Erste Verlaufsfarbe
gradientColor2stringNein-Zweite Verlaufsfarbe
gradientAnglenumberNein-Verlaufswinkel in Grad
blurEnabledbooleanNein-Hintergrund-Weichzeichnungseffekt aktivieren
blurIntensitynumberNein-Weichzeichnungsintensität (0-100)
shadowEnabledbooleanNein-Schlagschatten auf dem Motiv aktivieren
shadowOpacitynumberNein-Deckkraft des Schattens (0-100)
outputFormatstringNein-Ausgabeformat: png, webp oder avif
edgeRefineintegerNein-Stufe der Kantenverfeinerung (0-3)
decontaminatebooleanNein-Farbüberläufe an den Kanten entfernen

Beispielanfrage

bash
curl -X POST http://localhost:1349/api/v1/tools/image/remove-background \
  -F "[email protected]" \
  -F 'settings={"backgroundType":"transparent","edgeRefine":2,"outputFormat":"png"}'

Antwort

Erste Antwort (202 Accepted)

json
{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "async": true
}

Fortschritt (SSE unter /api/v1/jobs/{jobId}/progress)

event: progress
data: {"phase":"processing","stage":"Removing background...","percent":50}

Endergebnis (über SSE)

json
{
  "phase": "complete",
  "percent": 100,
  "result": {
    "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "downloadUrl": "/api/v1/download/{jobId}/photo_mask.png",
    "maskUrl": "/api/v1/download/{jobId}/photo_mask.png",
    "originalUrl": "/api/v1/download/{jobId}/photo_original.png",
    "originalSize": 245000,
    "processedSize": 180000,
    "filename": "photo.jpg",
    "model": "rembg"
  }
}

Effekt-Endpunkt (Phase 2)

POST /api/v1/tools/image/remove-background/effects

Wendet Hintergrundeffekte erneut an, ohne das KI-Modell neu auszuführen. Verwendet die zwischengespeicherte Maske und das Original aus Phase 1.

Parameter

ParameterTypErforderlichStandardBeschreibung
settingsJSONJa-JSON mit Effekteinstellungen (siehe unten)
backgroundImagefileNein-Eigenes Hintergrundbild (wenn backgroundType image ist)

JSON-Felder der Einstellungen

FeldTypErforderlichBeschreibung
jobIdstringJaJob-ID aus Phase 1
filenamestringJaUrsprünglicher Dateiname aus Phase 1
backgroundTypestringNeintransparent, color, gradient, blur, image
backgroundColorstringNeinHex-Farbe für einfarbigen Hintergrund
gradientColor1stringNeinErste Verlaufsfarbe
gradientColor2stringNeinZweite Verlaufsfarbe
gradientAnglenumberNeinVerlaufswinkel in Grad
blurEnabledbooleanNeinHintergrund-Weichzeichnung aktivieren
blurIntensitynumberNeinWeichzeichnungsintensität (0-100)
shadowEnabledbooleanNeinSchlagschatten aktivieren
shadowOpacitynumberNeinDeckkraft des Schattens (0-100)
outputFormatstringNeinpng, webp oder avif

Beispielanfrage

bash
curl -X POST http://localhost:1349/api/v1/tools/image/remove-background/effects \
  -F 'settings={"jobId":"a1b2c3d4-...","filename":"photo.jpg","backgroundType":"color","backgroundColor":"#FF5500","outputFormat":"png"}'

Antwort (200 OK)

json
{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "downloadUrl": "/api/v1/download/{jobId}/photo_nobg.png",
  "processedSize": 195000
}

Hinweise

  • Erfordert das installierte Modell-Bundle background-removal (4-5 GB).
  • Phase 1 speichert die transparente Maske und das Originalbild zwischen, sodass Phase 2 (Effekte) verschiedene Hintergründe sofort erneut anwenden kann, ohne das KI-Modell neu auszuführen.
  • Unterstützt die Eingabeformate HEIC/HEIF, RAW, TGA, PSD, EXR und HDR durch automatische Dekodierung.
  • Die EXIF-Rotation wird vor der Verarbeitung automatisch korrigiert.