Remove Background Image

免费增值
通过 Things4u | 已更新 il y a 2 mois | Video, Images
人气

9.3 / 10

延迟

7,388ms

服务等级

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)

关注者:2
API 创建者:
Rapid account: Things 4 U
Things4u
ntd119
登录并给 API 打分
打分:5 - 投票:1