Remove backgrounds from images and videos with AI — Carve.Photos API SDK for Python
Project description
carvesdk
Remove backgrounds from images and videos with the Carve.Photos API. Python SDK that handles uploads, polling, and downloads — pass a file, get the result.
Installation
pip install carvesdk
Quick Start
Remove background from image
from carvesdk import CarveClient
client = CarveClient("YOUR_API_KEY")
# Simple usage
result = client.remove_background("photo.jpg")
result.save("result.png")
# With parameters
result = client.remove_background(
"photo.jpg",
format="webp",
size="hd",
bg_color="#FFFFFF",
crop=True,
crop_margin="5%",
)
result.save("result.webp")
Remove background from video
from carvesdk import CarveClient
client = CarveClient("YOUR_API_KEY")
# Simple usage
result = client.remove_background_video("video.mp4")
result.save("result.mp4")
# With parameters
result = client.remove_background_video(
"video.mp4",
format="mp4",
processing_type="human",
background_color="#00B140",
start_time_sec=2.0,
end_time_sec=8.5,
)
result.save("result.mp4")
# Pro bundle (ZIP with alpha channel)
result = client.remove_background_video("video.mp4", format="pro_bundle")
result.save("result.zip")
Check balance
balance = client.get_balance()
print(f"Balance: {balance['total']} credits")
API Key
Get your API key at carve.photos/profile.
Free credits are included with registration.
Features
- Images: PNG, JPEG, WebP, AVIF — up to 25 megapixels
- Video: MP4, MOV, WEBM — up to 4K, 30 seconds
- Output formats: PNG, WebP, JPG, ZIP (images) / MP4, pro_bundle (video)
- Customization: crop, scale, position, ROI, background color/image
- Automatic polling: SDK handles status polling internally
Parameters
remove_background()
| Parameter | Type | Default | Description |
|---|---|---|---|
image |
str/Path/file | — | Image file (required) |
format |
str | "png" |
png, webp, jpg, zip |
size |
str | "auto" |
preview, medium, hd, full, auto |
bg_color |
str | None |
Hex color, e.g. "#FFFFFF" |
bg_image |
str/Path/file | None |
Background image file |
crop |
bool | False |
Crop to object bounds |
crop_margin |
str | None |
Margin, e.g. "10%" |
scale |
str | None |
Object scale, e.g. "75%" |
position |
str | None |
Position, e.g. "center" |
remove_background_video()
| Parameter | Type | Default | Description |
|---|---|---|---|
video |
str/Path/file | — | Video file (required) |
format |
str | "mp4" |
mp4 or pro_bundle |
processing_type |
str | "human" |
human or object |
background_color |
str | "#00B140" |
Hex color |
start_time_sec |
float | 0.0 |
Trim start (seconds) |
end_time_sec |
float | 0.0 |
Trim end (0 = full) |
Error Handling
from carvesdk import CarveClient
from carvesdk.client import CarveError
client = CarveClient("YOUR_API_KEY")
try:
result = client.remove_background("photo.jpg")
result.save("result.png")
except CarveError as e:
print(f"Error: {e}")
print(f"Status code: {e.status_code}")
print(f"Detail: {e.detail}")
Documentation
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file carvesdk-1.0.0.tar.gz.
File metadata
- Download URL: carvesdk-1.0.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9e9a57628f210cf64ff7e8397a0f7281ef59446923b865139650528b1d65698
|
|
| MD5 |
f2297d0093290bb94f312b3be1c934c6
|
|
| BLAKE2b-256 |
21b7a6429e19dbae69357f08d60959c111c587c8b0ef336e68936e605d0c7db1
|
Provenance
The following attestation bundles were made for carvesdk-1.0.0.tar.gz:
Publisher:
publish.yml on Carve-Photos/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
carvesdk-1.0.0.tar.gz -
Subject digest:
c9e9a57628f210cf64ff7e8397a0f7281ef59446923b865139650528b1d65698 - Sigstore transparency entry: 1243728203
- Sigstore integration time:
-
Permalink:
Carve-Photos/sdk-python@5753b7a93804845e4cb47ccbec7d367c50cf4fa9 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Carve-Photos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5753b7a93804845e4cb47ccbec7d367c50cf4fa9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file carvesdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: carvesdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1857c954dee7e1eee13802b5beeef141e83e584b9b0bfde77096dae4080f05f
|
|
| MD5 |
cc83501155eeba6bf0f35c1f72a85958
|
|
| BLAKE2b-256 |
911de49080a42e875761b29929e267c4f6450bf1a7bbf9d38d1ae1fef4e8b7fc
|
Provenance
The following attestation bundles were made for carvesdk-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on Carve-Photos/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
carvesdk-1.0.0-py3-none-any.whl -
Subject digest:
d1857c954dee7e1eee13802b5beeef141e83e584b9b0bfde77096dae4080f05f - Sigstore transparency entry: 1243728205
- Sigstore integration time:
-
Permalink:
Carve-Photos/sdk-python@5753b7a93804845e4cb47ccbec7d367c50cf4fa9 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Carve-Photos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5753b7a93804845e4cb47ccbec7d367c50cf4fa9 -
Trigger Event:
push
-
Statement type: