TidyTools

Image compress

POST https://tools.yukai.uk/api/v1/image/compress

Compress an image. Re-encodes with a lower quality (default 75) in the same format (format=auto) or in WebP, AVIF or JPEG, optionally scaled down with maxSize. Metadata (EXIF, GPS) is removed. If the result would not be smaller in the same format, the original bytes come back (unchanged: true, warning already_optimized). PNG input stays lossless PNG with format=auto: use format=webp for large savings. Typical time under 1 second. Send an image URL (GET or POST), a base64 image (POST JSON), a file upload (POST multipart/form-data, field image) or the raw image bytes (POST with Content-Type: image/*, options in the query string). The answer is the image itself by default (response=json for metadata + base64). One call = one image. The same image with the same options is answered from a 24-hour cache.

Cost

Credits: 18 ($0.0018) per successful call. Failed calls are free. Source price: ai-image-toolkit/image-processed.

Input

Send a JSON body (POST) or the same fields as a query string (GET).

No field is required.

FieldTypeDefaultDescription
urlstringPublic image URL (JPEG, PNG, WebP or GIF, up to 10 MB, 50 megapixels and 12,000 px per side). Private, local and cloud-metadata addresses are refused on every redirect. Alias: imageUrl. For POST you can send image (base64) or upload the file instead.
qualityinteger75Quality 1-100 (lower = smaller).
formatstring"auto"auto keeps the input format (GIF becomes PNG).
maxSizeintegerLongest side of the result in pixels; larger images are scaled down (never up), keeping the aspect ratio.
backgroundstringFill color for transparent areas when the result is JPEG (default white).
responsestring"image"image (default): the response body is the image itself (Content-Type: image/..., metadata in x-* headers). json: JSON with the metadata and the image as base64 in image (results up to 15 MB).
imagestringThe image itself as base64 or a data URL (data:image/png;base64,...), up to 10 MB decoded. POST only. Aliases: imageBase64, base64.

Examples

Replace tt_live_XXXX with your key from the pricing page.

curl

curl -i -X POST "https://tools.yukai.uk/api/v1/image/compress" \
  -H "Authorization: Bearer tt_live_XXXX" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/Smiling_senior_woman_with_curly_hair_portrait.jpg/960px-Smiling_senior_woman_with_curly_hair_portrait.jpg","quality":70,"response":"json"}'

JavaScript (fetch)

const res = await fetch("https://tools.yukai.uk/api/v1/image/compress", {
  method: "POST",
  headers: { "Authorization": "Bearer tt_live_XXXX", "Content-Type": "application/json" },
  body: JSON.stringify({"url":"https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/Smiling_senior_woman_with_curly_hair_portrait.jpg/960px-Smiling_senior_woman_with_curly_hair_portrait.jpg","quality":70,"response":"json"}),
});
console.log(res.status, res.headers.get("x-credits-charged"), res.headers.get("x-credits-balance"));
console.log(await res.json());

Python (requests)

import requests

r = requests.post(
    "https://tools.yukai.uk/api/v1/image/compress",
    headers={"Authorization": "Bearer tt_live_XXXX"},
    json={"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/Smiling_senior_woman_with_curly_hair_portrait.jpg/960px-Smiling_senior_woman_with_curly_hair_portrait.jpg", "quality": 70, "response": "json"},
    timeout=120,
)
print(r.status_code, r.headers.get("x-credits-charged"), r.headers.get("x-credits-balance"))
print(r.json())

Response

JSON with "success": true and the result fields; on failure {"success": false, "error": {"code", "message", "retryable"}} and no credits are used. Every answer carries x-credits-charged (credits used) and x-credits-balance (balance after the call); check the balance any time with GET https://tools.yukai.uk/v1/billing/balance.

Full field list and response schema: OpenAPI spec image-tools (its servers entry is the marketplace gateway; call https://tools.yukai.uk with your key).

← All routes · Pricing