Library for remove image background for node and python
To use this library you will need to have Python installed in your environment. Ensuring you have Python run the command:
pip install rembg
Now install our library
npm install remove-bg-node
Import the library on your system with
const RemoveBackground = require('remove-bg-node');
or
import RemoveBackground from 'remove-bg-node';
Now you must create an instance of your class.
let rm = new RemoveBackground();
We will call the main method and we will pass the directory of our image and the directory to which we must save our image without the background
full example
'use strict'
const RemoveBackground = require('remove-bg-node');
let rm = new RemoveBackground();
let current = __dirname + '/teste/cristian.jpg';
let save = __dirname + '/deploy';
await rm.asyncRemoveBackground(current, save)
ps:A file with the same name will be generated.
Result
Before:
After