Image Optimization API reference
Base URL: https://api.justapi.tech (alias: https://img.justapi.tech)
| Method | Path | Description | Modes |
|---|---|---|---|
POST |
/v1/image/optimize |
Optimize one image | sync |
POST |
/v1/image/batch |
Optimize up to 250 images | sync, async (sync: 10 images) |
options for POST /v1/image/optimize
"options": {
"width": 1600, "height": null, "fit": "inside", // inside | cover | contain | fill
"format": "jpeg", // jpeg | webp | avif | png | auto
"quality": 76,
"mozjpeg": true,
"progressive": false, // must be false if the output is embedded in a PDF
"chroma_subsampling": "4:2:0",
"strip_metadata": true,
"auto_orient": true, // applies EXIF rotation, THEN strips it
"max_bytes": 250000, // binary quality search until the output is under this
"keep_source": false // default: the original is deleted after processing
}
Two defaults exist specifically because getting them wrong is a common, hard-to-debug failure:
progressive: false. Progressive JPEG is not valid inside DCTDecode streams. Most PDF viewers
render it wrong or blank. If the destination is a PDF, always baseline.
auto_orient: true. Phone photos carry orientation in EXIF, not in the pixel data. Stripping
EXIF before rotating leaves every landscape photo sideways. We rotate first, then strip.
POST /v1/image/batch
Same options object applied to every image, plus an optional per_image_options keyed by ref
for per-file overrides. Up to 250 images (25 on the free tier). Individual failures do not fail the
batch — each result comes back tagged ok or failed against its own ref.
GET /v1/image/t/{key_id}/{transform}/{file_id}
URL-based transform, drop-in compatible with the Bytescale query-param pattern:
https://img.justapi.tech/t/k_7f3a/w_1200,q_76,f_jpg/fil_01JBX...
Transforms: w_ width, h_ height, q_ quality, f_ format, fit_, g_ gravity, bl_ blur,
sh_ sharpen, r_ rotate. Cached at Cloudflare's edge — a repeated request for the same transform
is a cache hit and is not billed again.
Example
curl https://api.justapi.tech/v1/image/optimize \
-H "Authorization: Bearer ak_live_..." \
-H "Content-Type: application/json" \
-d '{"source":{"url":"https://example.com/photo.jpg"},"options":{"width":1600,"max_bytes":250000}}'
Full envelope, error catalog and billing rule are the same across every JustAPI service — see the API reference index and error codes.