In-Browser AI Background Removal for Your Web Apps
Integrate Pixir's production AI engine into your own JavaScript and TypeScript projects. Powered by Bria AI RMBG-1.4 and WebGPU hardware acceleration. 100% private • Zero server calls • Zero cloud infrastructure costs.
Three Simple Steps to Get Started
Zero complicated model setups. The package automatically handles caching, WASM runtimes, and WebGPU fallback.
Install Package & Runtime
Install @pixir/background-remover alongside the onnxruntime-web peer dependency.
Import removeBackground
Pass any File, Blob, URL, or Canvas. The model compiles directly on the client's GPU.
Display or Download PNG
Receive a crisp 32-bit transparent PNG with hair wisps and edge detail preserved, ready for instant rendering or user download.
Framework Integration Guides
Works seamlessly in Vanilla JS, TypeScript, React 18, Next.js, and Canvas pipelines.
import { removeBackground } from "@pixir/background-remover";
const fileInput = document.getElementById("fileInput") as HTMLInputElement;
fileInput.addEventListener("change", async (e) => {
const file = fileInput.files?.[0];
if (!file) return;
// Execute in-browser AI segmentation
const resultBlob = await removeBackground(file, {
device: "auto", // WebGPU first, then WASM
refineEdges: true, // Guided filter edge refinement
progress: (info) => {
console.log(`[${info.stage}] ${Math.round(info.progress * 100)}%: ${info.message}`);
}
});
// Display cutout image
const url = URL.createObjectURL(resultBlob);
const img = document.createElement("img");
img.src = url;
document.body.appendChild(img);
});Full Configuration Options Reference
All parameters available in RemoveBackgroundOptions.
| Option | Type | Default | Description |
|---|---|---|---|
| device | 'auto' | 'webgpu' | 'wasm' | 'auto' | Execution provider backend. 'auto' prefers WebGPU, falling back to single-threaded WASM SIMD. |
| refineEdges | boolean | true | Runs Fast Guided Image Filter to preserve fine hair, pet fur, and translucent fabrics. |
| modelPath | string | Hugging Face CDN | Custom URL or relative path to self-hosted rmbg_quantized.onnx for offline environments. |
| wasmPath | string | jsDelivr CDN | Custom path for onnxruntime-web WASM binaries. |
| refinementOptions | RefinementOptions | {} | Fine-tuning: radius (default 3), eps (0.001), fgThreshold (0.95), bgThreshold (0.03), defringe (true). |
| outputType | 'image/png' | 'image/webp' | 'image/png' | Desired output MIME format when returning a Blob. |
| quality | number | 0.95 | Compression quality for lossy formats like webp (0.0 to 1.0). |
| progress | (info: ProgressInfo) => void | undefined | Granular callback reporting stage, percentage (0.0 to 1.0), and message. |
| signal | AbortSignal | undefined | AbortController signal to cancel download or inference operations. |
Why Developers Choose @pixir/background-remover
A modern client-side architecture without viral licensing hurdles.
| Capability | @pixir/background-remover | @imgly/background-removal | Cloud APIs (remove.bg) |
|---|---|---|---|
| Software License | MIT Permissive | AGPL v3 (Viral Copyleft) | Proprietary Closed |
| Privacy & Data Security | 100% Client-Side (Zero Server) | Client-Side | Images Sent to Third Party |
| Edge & Hair Quality | Bria RMBG-1.4 + Guided Filter | ISNet Downsampled | High |
| Hardware Acceleration | Native WebGPU + WASM SIMD | WASM Multi-thread chunks | Cloud Servers |
| Per-Image Cost | $0.00 (Zero Server Costs) | $0.00 (Requires AGPL) | $0.20 – $1.00 / image |
Frequently Asked Developer Questions
Answers to common architecture, deployment, and integration questions.
Try the Pixir Web Studio Live
Experience the native AI engine in our production studio with full 4K export and canvas tools.
Open Free Studio