TrimForge

TrimForge API Reference

A highly scalable async API for background removal, intelligent trimming, and image enhancement.

The Anatomy of a Request

We use an async event-driven architecture to ensure large files or complex ML models never timeout. All operations follow this flow:

1

Submit Job

Send your image to the processing endpoint. Receive a jobId instantly.

2

Poll Status

Check the status endpoint periodically (e.g., every 2s) until the job reads as "completed".

3

Fetch Result

Download the processed image base64 or optimized URL from the result endpoint.

Frontend Flow Example
async function processImage(endpoint, file) {
  const formData = new FormData();
  formData.append("image", file);

  // 1. Submit job
  const { statusUrl, resultUrl } = await (
    await fetch(endpoint, { method: "POST", body: formData })
  ).json();

  // 2. Poll until done
  let status;
  do {
    await new Promise((r) => setTimeout(r, 2000));
    status = await (await fetch(statusUrl)).json();
  } while (status.status === "processing");

  // 3. Get result
  if (status.status === "completed") {
    const result = await (await fetch(resultUrl)).json();
    return result.image;
  }
}

Auto Trim

Automatically crops completely transparent or solid white edges from subjects. Uses native hardware acceleration.

POST/api/trim

Request Body (multipart/form-data)

  • imageFile (Required) - Max 100MB
202 Accepted Response
{
  "success": true,
  "jobId": "740cbe8d-9f5a-4424-99a3-0d926e9eec00",
  "status": "processing",
  "message": "Trim job started. Poll the status URL to check progress.",
  "statusUrl": "https://api.trimforge.com/api/jobs/740cbe8d-.../status",
  "resultUrl": "https://api.trimforge.com/api/jobs/740cbe8d-.../result"
}

Background Removal

AI-powered isolation of primary subjects. Runs on isolated GPU clusters via ONNX Runtime.

POST/api/removebg
202 Accepted Response
{
  "success": true,
  "jobId": "5137cff4-87f7-4337-955d-4ecc7f1ce89b",
  "status": "processing",
  "message": "Background removal started. Poll the status URL to check progress.",
  "statusUrl": "https://api.trimforge.com/api/jobs/5137cff4-.../status",
  "resultUrl": "https://api.trimforge.com/api/jobs/5137cff4-.../result"
}

Image Enhancement

Programmatically adjust exposure, contrast, saturation, and apply unsharp masking.

POST/api/enhance

Request Body (multipart/form-data)

FieldTypeDefaultDescription
imageFileRequiredThe image to enhance
sharpenText1.5Sharpening strength (sigma)
brightnessText1.05Multiplier (1.0 = no change)
saturationText1.15Multiplier (1.0 = no change)

Status & Results

Use the endpoints returned in your initial request to poll for and retrieve the final payload.

1. Check Status

GET/api/jobs/:jobId/status
200 OK Response
{
  "success": true,
  "jobId": "5137cff4-...",
  "type": "enhance",
  "status": "completed", // 'processing', 'completed', 'failed'
  "resultUrl": "https://api.trimforge.com/api/jobs/5137cff4-.../result"
}

2. Fetch Payload

GET/api/jobs/:jobId/result
200 OK Response
{
  "success": true,
  "jobId": "5137cff4-...",
  "type": "enhance",
  "filename": "enhanced-photo.png",
  "mimeType": "image/png",
  "size": 2424283,
  "image": "data:image/png;base64,iVBORw0KGgo..."
}