Skip to main content
TransConvert

Image Compression API

Shrink JPG, PNG, WEBP, and GIF files with one POST request — same format in, same format out, aimed at a target percentage of the original size.

POST https://transconvert.com/api/v1/convert.php

Parameters

Field Description
AuthorizationRequired. "Bearer tc_live_...".
categorySet to "image-compress".
target_percentOptional, 1–100 (default 60). Target size as a rough percentage of the original — smaller compresses harder.
fileRequired. JPG, PNG, WEBP, or GIF.

Examples

TransConvert
curl -X POST \
  https://transconvert.com/api/v1/convert.php \
  -H "Authorization: Bearer tc_live_your_key_here" \
  -F "category=image-compress" \
  -F "target_percent=50" \
  -F "file=@photo.jpg" \
  -o output.jpg

Response

On success (200): the converted file's raw bytes, with Content-Type and Content-Disposition headers set for it. On failure: a JSON body shaped {"error": {"code": "...", "message": "..."}} with a matching HTTP status code — see Errors below.

Header Value
Content-TypeThe converted file's real MIME type (e.g. image/png, application/pdf).
Content-Dispositionattachment; filename="..." — a suggested filename, same as any file download.
Content-LengthSize of the response body in bytes.
X-Original-SizeThe uploaded file's size in bytes, before compression.
X-Saved-PercentRoughly how much smaller the result is than the original, as a whole-number percentage (can be 0).

Every error follows the same JSON shape, for example a quota being exceeded:

429 Too Many Requests
{
  "error": {
    "code": "quota_exceeded",
    "message": "Monthly API allowance of 5000 conversion-minutes reached.",
    "limit": 5000,
    "used": 5000
  }
}

Errors

Every failure returns a JSON error envelope with a "code" your code can branch on, plus a human-readable "message". Some errors include extra fields (quota_exceeded includes "limit" and "used", for example).

Status & code When it happens
401 missing_keyNo Authorization header was sent.
401 invalid_keyThe key doesn't exist, or has been revoked.
403 account_suspendedThe account owning this key is suspended.
403 plan_requiredThe account is on the Free plan — API access needs Basic, Lite, Pro, or Team.
400 invalid_category"category" wasn't "image" or "document".
400 no_fileNo file was sent, or the upload failed — the field must be named "file".
413 file_too_largeThe file exceeds your plan's max upload size.
429 quota_exceededThe plan's monthly conversion-minutes allowance is used up. Resets at the start of the next calendar month.
429 concurrency_limitToo many conversions already running at once for this account (shared with the website) — wait for one to finish and retry.
422 conversion_failedThe file itself couldn't be converted — "message" explains why. The status code varies with the reason: 400/415/422 mean the file or target won't work no matter how many times you retry; 500/503 mean a server-side problem, and 503 specifically is worth a short retry.

Supported formats

JPG, PNG, WEBP, GIF

Related