Input image as File, Blob, ArrayBuffer, HTMLImageElement, or HTMLCanvasElement
Processing options
Promise
// Basic usage
const fileInput = document.getElementById('file') as HTMLInputElement;
const file = fileInput.files[0];
const result = await remove(file);
// With progress tracking
const result = await remove(file, {
onProgress: (info) => console.log(`${info.step}: ${info.progress}%`)
});
// Mask only output
const mask = await remove(file, { onlyMask: true });
// Custom background color
const result = await remove(file, {
bgcolor: [255, 0, 0, 255] // Red background
});
When input type is not supported
When model fails to generate masks
When browser doesn't support required features (WASM, IndexedDB, etc.)
Remove background from an image using AI-powered segmentation.
This is the main function for background removal. It supports multiple input formats and provides various processing options including mask-only output, custom backgrounds, and post-processing.