AI Background Remover

FREEMIUM
Durch Firdavs Shodiyev | Aktualisiert il y a 2 mois | Artificial Intelligence/Machine Learning
Popularität

9.3 / 10

Latenz

2,864ms

Service Level

100%

Health Check

N/A

Zurück zu allen Diskussionen

What data is returning this API

Rapid account: Upardhi
upardhi
il y a 25 jours

Background removal is occurring, the API is returning the image without its background.

I aim to store the background-removed image elsewhere, such as on a CDN server, but I’m encountering difficulty due to the unspecified content type or lack of documentation regarding the API. Could you please assist me with this?

Rapid account: Upardhi
upardhi Commented il y a 24 jours

@firdavscoder1 : i am getting the response of image but when I am trying to save it in my local directory or on cloudeflare its throwing the error or invalid image . I am not sure what is reponse I am getting

Need Help

const removeBackgroundOfImage = async (req) => {
const { path } = req.body;
const removeBackgroundSettings = await db.RemoveBackgroundSettings.findOne({
where: {
isActive: true,
},
});

if (!removeBackgroundSettings) {
throw new Error(“RemoveBackgroundSettings not found”);
}
if (!path) {
throw new Error(“Path not found”);
}
const imageStream = await getStreamFromURL(path);
const formData = new FormData();
formData.append(“file”, imageStream); // Append the image path directly
const options = {
method: “POST”,
url: removeBackgroundSettings.url,

data: formData,

};
options.headers = {
[removeBackgroundSettings.headerKey]: removeBackgroundSettings.headerValue,
[removeBackgroundSettings.headerHostKey]:
removeBackgroundSettings.headerHostValue,
…formData.getHeaders(),
responseType: “stream”, // To handle the binary response properly
};
const response = await axios.request(options);

//Create image and upload on cloudeflare and return the path
const folderName = “temp”; // Replace “your_folder” with your desired folder name
const directory = path.join(process.cwd(), folderName);
const filePath = path.join(directory, filename);

try {
fs.writeFile(filename, content, “binary”, (err) => {
if (err) {
console.error(“Error saving the file:”, err);
return;
}
console.log(“File saved successfully!”);
});
return filePath;
} catch (err) {
throw new Error(Error saving the file: ${err.message});
return res;
};

Rapid account: Firdavscoder 1
firdavscoder1 Commented il y a 25 jours

Hi.

Can you specifiy the error with a screenshot, please ? I guess it is solved by some coding. You can save the result as an image on your local and send it to the server. If you want, you can write to my email firdavscoder1@gmail.com

Nehmen Sie an der Diskussion teil - fügen Sie unten einen Kommentar hinzu:

Anmelden / Registrieren, um neue Kommentare zu veröffentlichen