Add local background removal and mask tools
This commit is contained in:
26
src/tools/background-remover/run.ts
Normal file
26
src/tools/background-remover/run.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { ToolInput } from "../../core/io/input-types";
|
||||
import type { ToolResult } from "../../core/io/output-types";
|
||||
import type { ToolContext } from "../../core/plugins/plugin-types";
|
||||
import { removeImageBackground, type BackgroundRemoverOptions } from "./remove";
|
||||
|
||||
export async function runBackgroundRemover(
|
||||
input: ToolInput,
|
||||
options: BackgroundRemoverOptions,
|
||||
context: ToolContext
|
||||
): Promise<ToolResult> {
|
||||
const files = input.files;
|
||||
|
||||
if (!files || !Array.isArray(files) || files.length === 0) {
|
||||
throw new Error("No image provided.");
|
||||
}
|
||||
|
||||
const file = files[0];
|
||||
|
||||
return removeImageBackground(
|
||||
file.name,
|
||||
file,
|
||||
options,
|
||||
self.location.origin,
|
||||
context.reportProgress
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user