AI Background Remover

フリーミアム
よって Firdavs Shodiyev | 更新済み hace un mes | Artificial Intelligence/Machine Learning
人気

9.2 / 10

レイテンシー

2,606ms

サービスレベル

100%

Health Check

N/A

すべてのディスカッションに戻る

What data is returning this API

Rapid account: Upardhi
upardhi
hace 18 días

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 hace 17 días

@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 hace 18 días

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

ディスカッションに参加しましょう-以下にコメントを追加してください:

ログイン/サインアップして新しいコメントを投稿