AI Background Remover

FREEMIUM
Popularité

9.3 / 10

Latence

2,864ms

Niveau de service

100%

Health Check

N/A

Retour à toutes les discussions

What data is returning this API

Rapid account: Upardhi
upardhi
25 giorni fa

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 24 giorni fa

@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 25 giorni fa

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

Participez à la discussion - ajoutez un commentaire ci-dessous:

Connectez-vous / Inscrivez-vous pour publier de nouveaux commentaires