Compress an image to a target size
POST
/v1/compressAuthorization
AuthorizationBearer token · headerrequiredikb_live_… keys are issued manually — see /api/authentication. Ask for one at privacy@imagekbreducer.com.
Request body
requiredmultipart/form-datafilestringrequiredJPEG, PNG, or WebP. HEIC and AVIF are refused with 415 before any decode is attempted — this Worker cannot decode either (see /api/errors and /api/limits). Use the CLI or the web app for HEIC sources; for AVIF, convert first — the CLI runs this same wasm backend and refuses AVIF too, and the web app decodes AVIF only where the browser itself does.
targetstringrequired1024-based: 50kb is 51 200 bytes.
formatstringdefault: "keep"
Allowed:
keepjpegpngwebpallow_downscalebooleanMay the search shrink pixel dimensions to reach the target? With false, dimensions win and target-unreachable is possible.
default: true
Responses
200The compressed image.
string400Error
errorstringrequiredAllowed:
bad-requestempty-fileunauthorizedlength-requiredinput-too-largeunsupported-formatdecode-faileddimension-exceededtarget-unreachablerate-limitedrate-limiter-unavailableprocessing-timeoutnot-foundinternalmessagestringrequired401Error
errorstringrequiredAllowed:
bad-requestempty-fileunauthorizedlength-requiredinput-too-largeunsupported-formatdecode-faileddimension-exceededtarget-unreachablerate-limitedrate-limiter-unavailableprocessing-timeoutnot-foundinternalmessagestringrequired411Error
errorstringrequiredAllowed:
bad-requestempty-fileunauthorizedlength-requiredinput-too-largeunsupported-formatdecode-faileddimension-exceededtarget-unreachablerate-limitedrate-limiter-unavailableprocessing-timeoutnot-foundinternalmessagestringrequired413Error
errorstringrequiredAllowed:
bad-requestempty-fileunauthorizedlength-requiredinput-too-largeunsupported-formatdecode-faileddimension-exceededtarget-unreachablerate-limitedrate-limiter-unavailableprocessing-timeoutnot-foundinternalmessagestringrequired415Error
errorstringrequiredAllowed:
bad-requestempty-fileunauthorizedlength-requiredinput-too-largeunsupported-formatdecode-faileddimension-exceededtarget-unreachablerate-limitedrate-limiter-unavailableprocessing-timeoutnot-foundinternalmessagestringrequired422target-unreachable (an answer, not a failure), decode-failed, or dimension-exceeded.
errorstringrequiredAllowed:
bad-requestempty-fileunauthorizedlength-requiredinput-too-largeunsupported-formatdecode-faileddimension-exceededtarget-unreachablerate-limitedrate-limiter-unavailableprocessing-timeoutnot-foundinternalmessagestringrequiredreasonstringAllowed:
FIXED_DIMENSIONSMIN_DIMENSIONFORMAT_FLOORBUDGET_EXHAUSTEDclosestintegerBytes of the smallest file the search produced.
suggestionsobject[]Show propertiesHide properties
Array of
objectkindstringrequiredAllowed:
allow-downscaleswitch-formatraise-targetaccept-closestkeep-searchinglower-min-qualityformatstringbytesintegeradditionalEncodesintegerminQualityinteger429Error
errorstringrequiredAllowed:
bad-requestempty-fileunauthorizedlength-requiredinput-too-largeunsupported-formatdecode-faileddimension-exceededtarget-unreachablerate-limitedrate-limiter-unavailableprocessing-timeoutnot-foundinternalmessagestringrequired500Error
errorstringrequiredAllowed:
bad-requestempty-fileunauthorizedlength-requiredinput-too-largeunsupported-formatdecode-faileddimension-exceededtarget-unreachablerate-limitedrate-limiter-unavailableprocessing-timeoutnot-foundinternalmessagestringrequired503Error
errorstringrequiredAllowed:
bad-requestempty-fileunauthorizedlength-requiredinput-too-largeunsupported-formatdecode-faileddimension-exceededtarget-unreachablerate-limitedrate-limiter-unavailableprocessing-timeoutnot-foundinternalmessagestringrequired