Browser, CLI, or Node.js for background removal?
Use the browser when a person is choosing and checking an image. Use the CLI for file automation. Use the Node.js API when background removal belongs inside application code.
Published
Use the browser for interactive work
The hosted browser app is the shortest path when a person has an image and wants a transparent result. It supports choosing, dragging, or pasting an image and shows the original and cutout together for inspection.
The browser path runs inference on the device with WebGPU when available and can use WebAssembly as a local fallback.
Do not automate the browser just to process a folder. The CLI already has a file and directory contract for that job.
Use the CLI for files and shell automation
The CLI fits scripts, build steps, scheduled jobs, and directories. It can accept one image, several images, or a directory and write the results as files.
Batch processing is sequential and reuses one warm runtime. You can choose output format and require GPU or CPU when the environment needs a specific engine.
npx bgcut photo.jpg
npx bgcut photos/ -o ./cutouts
Use Node.js inside an application
The Node.js API fits servers, desktop applications, workers on your own machine, and other JavaScript code that needs background removal as one step in a larger process.
Create one bgcut instance, reuse it, and close it when finished. removeMany accepts files, directories, iterables, and async iterables when your application owns the input stream.
import { bgcut } from "bgcut";
const remover = await bgcut();
try {
const result = await remover.removeBackground("photo.jpg");
console.log(result.width, result.height, result.format);
} finally {
await remover.close();
}
The interface changes, the local contract does not
The hosted browser runs the browser model locally. The CLI and Node.js API run the native runtime locally. Choosing an interface does not turn bgcut into a hosted image-processing service.
Pick the interface based on who controls the job. A person usually wants the browser. A shell script usually wants the CLI. Application code usually wants the Node.js API.