Skip to content

makidoll/transparent-background-npm

Repository files navigation

Transparent Background (npm)

transparent-background lets you easily remove backgrounds from images

Powered by InSPyReNet (ACCV 2022), thanks to @plemeri for creating transparent-background

  • Python must be installed system-wide
  • Works on Linux, macOS and Windows
    • Python is already pre-installed on macOS
    • If failing on Windows, you might have to install Python 3.8
pnpm install transparent-background
yarn add transparent-background
npm install transparent-background

Example

Before and after

import * as fs from "fs/promises";
import { transparentBackground } from "transparent-background";

// const fs = require("fs/promises");
// const { transparentBackground } = require("transparent-background");

(async () => {
	const input = await fs.readFile("test-input.png");

	const output = await transparentBackground(input, "png", {
		// uses a 1024x1024 model by default
		// enabling fast uses a 384x384 model instead
		fast: false,
	});

	await fs.writeFile("test-output.png", output);
})();

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published