LassoCut for Python
Official Python client for the LassoCut API: remove the background of an image, frame it for a marketplace, add a cast shadow. Python 3.10 or later, no dependencies (standard library only).
pip install lassocut
from lassocut import LassoCut
client = LassoCut() # reads LASSOCUT_API_KEY; or LassoCut(api_key="...")
client.remove_background_file("photo.jpg", "photo-cutout.png")
Get a key in your LassoCut account. Each account gets 50 free previews a month (up to 10 a day); full-size results use credits.
Usage
from lassocut import LassoCut, LassoCutError
client = LassoCut()
# A path, bytes or a binary file object; or image_url="https://..."
result = client.remove_background("photo.jpg", size="preview")
result.save("photo-cutout.png") # result.data holds the bytes
print(result.credits_charged) # 0.25 for a preview, 1 for full size, 0 for a free preview
print(result.width, result.height) # size of the returned image
print(result.type, result.foreground) # subject type, (top, left, width, height)
# A coloured background and a crop to the subject
client.remove_background_file("shoe.jpg", "shoe.jpg", bg_color="ffffff", crop=True, format="jpg")
# Balance
balance = client.credits()
print(balance.credits, balance.free_previews)
remove_background takes size (preview, full, 50MP or auto, default auto), type, format,
channels, bg_color, bg_image (path, bytes or file), bg_image_url, crop, crop_margin, scale,
position, preset, shadow, light_angle, shadow_length, shadow_strength, and extra={...} for any other
API field (for example extra={"roi": "0% 0% 100% 100%"}). The fields are described in the
API reference.
remove_background_file(input_path, output_path=None, **options) writes the result; without output_path it
writes <name>-lassocut.<ext> next to the input, the extension following the returned format.
Marketplace presets and cast shadow
result = client.remove_background("product.jpg", preset="amazon")
result.save("product-amazon.jpg")
print(result.preset, result.compliant, result.compliance_reasons) # amazon True []
client.remove_background_file("product.jpg", "product-shopify.jpg", preset="shopify",
shadow="cast", light_angle=30, shadow_length="long", shadow_strength=55)
preset is one of amazon, ebay, etsy, shopify, zalando, instagram. A preset decides the format,
background and framing itself, so it cannot be combined with format, channels, bg_color, bg_image,
bg_image_url, crop, crop_margin, scale or position (a ValueError is raised before any call).
Results are JPG files. result.compliant is True when the result meets the preset; compliant means compliant
with the image rules LassoCut checks. result.upscaled is True when the product had to be enlarged to fill the
canvas.
shadow="cast" adds a cast shadow: light_angle from -90 to 90 (positive = light from the left, default 45),
shadow_length short, medium or long (default medium), shadow_strength from 0 to 100. Zalando allows no
shadow, so with preset="zalando" the shadow options are ignored with a LassoCutWarning.
Errors and retries
Temporary server errors (502, 503, 504) are retried automatically, 3 attempts in all with a short backoff. Every
attempt carries the same Idempotency-Key, so a retried call is charged once. Other failures raise
LassoCutError with status, code (for example unknown_foreground), title, detail and, for 429,
retry_after:
try:
client.remove_background("photo.jpg")
except LassoCutError as e:
print(e.status, e.code, e)
Options: LassoCut(api_key=None, api_url=None, timeout=180, max_attempts=3, backoff=1.0). api_url defaults to
LASSOCUT_API_URL, then https://api.lassocut.com/v1.0.
Migrating from remove.bg
The remove.bg API closes on 1 December 2026. LassoCut's POST /v1.0/removebg takes the same request fields and
the same X-Api-Key header, and returns the image bytes with the same kind of response headers, so existing code
needs the base URL and the key changed:
import requests
r = requests.post(
- "https://api.remove.bg/v1.0/removebg",
- headers={"X-Api-Key": REMOVE_BG_KEY},
+ "https://api.lassocut.com/v1.0/removebg",
+ headers={"X-Api-Key": LASSOCUT_API_KEY},
files={"image_file": open("photo.jpg", "rb")},
data={"size": "auto"},
)
Or with this package:
from lassocut import LassoCut
LassoCut().remove_background_file("photo.jpg", "no-bg.png", size="auto")
If LASSOCUT_API_KEY is not set, the client also reads REMOVE_BG_API_KEY, so a script configured for the old
service runs once you put a LassoCut key in that variable. LassoCut is an independent service, not affiliated with
remove.bg. More in the migration guide.
Development
python -m pytest # or: python -m unittest discover -s tests
python -m build # sdist and wheel in dist/
The tests run against a local stub server: no network and no key needed.
License
MIT, Copyright (c) 2026 JAUPIN Design LLC.
Metadata
Release files for lassocut 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lassocut-0.1.0.tar.gz | 13.4 kB | With provenance | Details for lassocut-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lassocut-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for lassocut-0.1.0-py3-none-any.whl |
Total release size: 24.5 kB
Release files / lassocut-0.1.0.tar.gz
| Download URL | lassocut-0.1.0.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8f053df538d33c7a8a6bf23320d1ab9ea1ca029418537a348a13ffb7ceb2ed7
|
|
BLAKE2b-256 checksum How to use checksums |
e4d2d594af9221da4677c9f5f36d39e4f8be4a91010656e60e4705e580cd3dca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / lassocut-0.1.0-py3-none-any.whl
| Download URL | lassocut-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
35954395b1e867e43a48a968991a5ba927038c950e5b6c3a54ae90c20e9537c9
|
|
BLAKE2b-256 checksum How to use checksums |
ba87fe8ed3525d38e321e45f8a7fd0f160450cb451d5db624026caafa6146d2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for lassocut 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for lassocut-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.