Background Removal

Remove backgrounds from images using Cloudflare Image Transformations

Live Examples

Original Image

No processing Original
1600 × 916

Default Settings

padding=7 & square=true Default
1858 × 1858 (7% min padding)

More Padding

padding=15 & square=true 15% padding
2283 × 2283 (15% min padding)

Tight Crop

padding=2 & square=true 2% padding
1665 × 1665 (2% min padding)

Keep Aspect Ratio

padding=7 & square=false Non-square
1822 × 1138 (original ratio)

Simple Mode

simple=true Simple
1600 × 916 (no trim/pad)

Skip BG Removal

nobg=true (2 CF reqs) No BG removal
Already transparent input

API Reference

GET /proxy

Returns processed image with background removed, trimmed, padded, and optionally squared

url Image URL (required)
padding Minimum padding % on all sides (default: 7)
square Make square output (default: true)
margin Safety margin % for edge detection (default: 5)
alpha Alpha threshold 0-255, lower = more opaque (default: 3)
format Output format: png, webp, avif (default: png)
quality Quality 1-100
simple Set to "true" for basic bg removal only (no trim/pad)
nobg Skip background removal (image already transparent) - saves 2 CF requests
GET /proxy?url=https://example.com/photo.jpg&padding=7&square=true GET /proxy?url=https://example.com/transparent.png&nobg=true&padding=7 GET /proxy?url=https://example.com/photo.jpg&padding=10&square=false GET /proxy?url=https://example.com/photo.jpg&simple=true
GET /position

Returns positioning data OR cropped image (0 CF requests) - no background removal

url Image URL (required)
padding Minimum padding % on all sides (default: 7)
square Make square output (default: true)
margin Safety margin % for OpenCV detection (default: 2)
download Return actual cropped PNG instead of JSON (default: false)
format Output format: png, webp (only with download=true)
GET /position?url=https://example.com/photo.jpg&padding=7&square=true GET /position?url=https://example.com/photo.jpg&download=true
GET /debug

Returns JSON with processing details (bounding box, dimensions, etc.)

GET /debug?url=https://example.com/photo.jpg&padding=7&square=true