Remove Background Image

FREEMIUM
By Things4u | Updated un mese fa | Video, Images
Popularity

9.4 / 10

Latency

7,277ms

Service Level

100%

Health Check

N/A

README

How to use API

Using Python - You can use other programming languages.

1. Remove the image background from the URL

import requests
import base64

url = "https://remove-background-image2.p.rapidapi.com/remove-background"
querystring = {"image_url": "https://raw.githubusercontent.com/ntd119/public_data/main/images/heart.jpg"}
headers = {
    "X-RapidAPI-Key": "Your RapidAPI Key",
    "X-RapidAPI-Host": "remove-background-image2.p.rapidapi.com"
}
response = requests.request("POST", url, headers=headers, params=querystring)
data = response.json()

status = data.get("status")
if status:
    image = data.get("image")
    image_bytes = base64.b64decode(image)
    with open("image_output.png", "wb") as binary_
        binary_file.write(image_bytes)

2. Remove the image background from the local file

import requests
import base64

url = "https://remove-background-image2.p.rapidapi.com/remove-background"
files = {'file': open("C:/Users/admin/Downloads/heart.jpg", 'rb')}
headers = {
    "X-RapidAPI-Key": "Your RapidAPI Key",
    "X-RapidAPI-Host": "remove-background-image2.p.rapidapi.com"
}
response = requests.request("POST", url, headers=headers, files=files)
data = response.json()
status = data.get("status")
if status:
    image = data.get("image")
    image_bytes = base64.b64decode(image)
    with open("image_output.png", "wb") as binary_
        binary_file.write(image_bytes)

Followers: 2
API Creator:
Rapid account: Things 4 U
Things4u
ntd119
Log In to Rate API
Rating: 5 - Votes: 1