AI Background Remover

免费增值
人气

9.3 / 10

延迟

2,864ms

服务等级

100%

Health Check

N/A

返回所有讨论

What data is returning this API

Rapid account: Upardhi
upardhi
25日前

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日前

@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日前

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

加入讨论 - 在下面添加评论:

登录/注册以发布新的评论