Bytefusedocs

Image

Compress Image

Shrink an image at a quality dial — mozjpeg for JPEG, lossy palette quantization for PNG, quality-based WebP/AVIF. A never-grow guard means you never get back a larger file.

Free to try — no key required 10 credits / callSynchronous

Overview

Upload an image; receive a public R2 URL for the compressed version. The source format is kept. On the free-try path.

POSThttps://api.bytefuse.in/api/v1/image/compress

Request

Content type multipart/form-data:

filefilerequired
The image to compress — any Pillow-decodable format (JPEG, PNG, WebP, AVIF, …).
qualityintoptional
1–100; lower is smaller. Applies to JPEG/WebP/AVIF, and drives PNG lossy palette quantization.Default: 70

No format change here

Compress keeps the source format — there’s no target_format field. To change format, use Convert Image. AVIF output needs the optional server plugin, otherwise returns 422.

Response

200 OK, application/json:

200 OK
{
  "success": true,
  "url": "https://<r2-host>/image/20260704/<uuid>.jpg",
  "meta": {
    "original_size": 2048576,
    "output_size": 512000,
    "format": "JPEG",
    "width": 1920,
    "height": 1080,
    "original_dimensions": "1920x1080",
    "processing_time_ms": 180
  },
  "credits_charged": 1
}

url is a public R2 link (permanent under the default config; no expires_at). X-Credits-Charged mirrors credits_charged (0 anonymous).

Examples

curl -X POST https://api.bytefuse.in/api/v1/image/compress \
  -F "file=@photo.jpg" \
  -F "quality=60"
# Add -H "X-API-Key: dt_live_your_key" to run authenticated (10 credits).

Errors

422An invalid/unsupported image, an unavailable format (e.g. AVIF without the plugin), or quality out of 1–100.
402 / 429 / 503Insufficient credits (authenticated), rate limited, or capacity/config error.
500The image engine failed unexpectedly.

See Resize Image and Convert Image for the other image tools.