Batch background remover for files and folders
Use one local runtime for a set of images instead of starting a separate inference process for every file.
Batch from the command line
Pass several files in one command or give bgcut a directory. Directory input is scanned recursively for supported images.
npx bgcut first.jpg second.png
npx bgcut photos/ -o ./cutoutsBatch from Node.js
removeMany also accepts a directory, iterable, or async iterable. That lets the caller own discovery or stream work from another part of the application.
import { bgcut } from "bgcut";
const remover = await bgcut();
try {
for await (const item of remover.removeMany("photos")) {
if (!item.ok) {
console.error(item.source.input, item.error);
continue;
}
console.log(item.result);
}
} finally {
await remover.close();
}Sequential work is deliberate
bgcut processes the batch sequentially and keeps one runtime warm. It does not assume every machine has the memory or GPU capacity to run several model sessions at once.