@xixiyahaha/rembg-node
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

Rembg Node

Ori repo : https://github.com/makifoxgirl/rembg-node

change: sharp version.

Rembg lets you easily remove backgrounds from images using the U2-Net AI model

This is a loose port of the original Rembg for Python, big thanks to @danielgatis

It uses sharp for input and output so you can easily integrate it

The masking algorithm isn't fully complete yet, but the results are pretty good already!

yarn add sharp @xixiyahaha/rembg-node

npm install sharp @xixiyahaha/rembg-node

Example

import { Rembg } from "@xixiyahaha/rembg-node";
import sharp from "sharp";

// const { Rembg } = require("rembg-node");
// const sharp = require("sharp");

(async () => {
	const input = sharp("test-input.jpg");

	// optional arguments
	const rembg = new Rembg({
		logging: true,
	});

	const output = await rembg.remove(input);

	await output.webp().toFile("test-output.webp");

	// optionally you can use .trim() too!
	await output.trim().webp().toFile("test-output-trimmed.webp");
})();

Readme

Keywords

none

Package Sidebar

Install

npm i @xixiyahaha/rembg-node

Weekly Downloads

53

Version

2.2.0

License

MIT

Unpacked Size

18.8 kB

Total Files

7

Last publish

Collaborators

  • vxooxv