Input image as File, Blob, ArrayBuffer, HTMLImageElement, or HTMLCanvasElement
Processing options
Promise
// Get canvas for further processing
const canvas = await removeToCanvas(file);
const ctx = canvas.getContext('2d');
// Perform additional canvas operations...
// Convert to blob when ready
const blob = await new Promise(resolve =>
canvas.toBlob(resolve, 'image/png')
);
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 and return as HTMLCanvasElement.
Similar to the
remove()function but returns a canvas instead of a blob. This is useful when you need to perform additional canvas operations or want to avoid the blob conversion overhead.