Resize, crop, compress and convert with 1 API call
Integrate image editing into your app or workflow. POST an image with the dimensions, crop, format and file-size budget you want — get the optimized bytes straight back. Pure CPU processing, no queue, no cold starts.
Get API KeyNot a developer? Use the web app instead — no code required.
Easy to integrate
A simple HTTP interface with sensible options:
- Source images
- Direct upload (
image_file), a URL (image_url), or a base64 string (image_base64). JPG, PNG, WebP, GIF, TIFF and AVIF in — up to 50 MB and 64 megapixels. - Result images
- Binary image file by default, or JSON-encoded data (base64 + dimensions) with
Accept: application/json. - Output resolution
- Any size up to 8000×8000 px, full resolution, never watermarked.
Get started
Create an API key in your dashboard, then send your first request. Optimization calls are free by default; failed calls are never charged. Authenticate with X-Api-Key: rs_live_… (or Authorization: Bearer rs_live_…).
Sample code
Resize to 1200px wide, convert to WebP and stay under 200 KB:
curl -H "X-Api-Key: rs_live_..." \
-F "image_file=@/path/to/photo.jpg" \
-F "width=1200" \
-F "format=webp" \
-F "target_kb=200" \
-f https://usely.tools/api/v1/resize \
-o photo-1200.webpCut an exact region with a smart crop:
# Smart-crop a 1080×1080 square around the most interesting region,
# then resize is skipped (crop output IS the result)
curl -H "X-Api-Key: rs_live_..." \
-F "image_file=@banner.jpg" \
-F "crop_width=1080" -F "crop_height=1080" \
-F "gravity=attention" \
-f https://usely.tools/api/v1/resize -o square.jpgOutput formats
Request one of the formats below via the format parameter, or omit it (keep) to stay in the input format.
| Format | Transparency | Pros & cons |
|---|---|---|
jpeg | No | + Smallest for photos · + Universal · − No transparency (flattened onto the pad color) |
png | Yes | + Lossless · + Transparency · − Larger files (quality/target_kb do not apply) |
webp | Yes | + Small files with transparency · + Every modern browser · − Not for legacy tooling |
avif | Yes | + Best compression per quality · − Slower to encode · − Limited legacy support |
tiff | No | + Print/archival workflows · − Very large files |
ico | Yes | + Favicons (auto-capped at 256px) · − Only useful as an icon |
For photos on the web, webp with a target_kb budget is the sweet spot. Use png when you need pixel-perfect graphics or lossless transparency.
API Reference
POST /api/v1/resize
Resizes, crops, compresses and/or converts a JPG / PNG / WebP / GIF / TIFF / AVIF image. File size up to 50 MB; input up to 64 megapixels; output up to 8000 px per side. Requires an API key in the X-Api-Key header (or a Bearer token in Authorization). All parameters are optional — with none, the call is a pure re-encode.
Request body — multipart/form-data or application/json
| Parameter | Type | Description |
|---|---|---|
image_file | binary | Source image file (multipart). Exactly one image source is required. |
image_base64 | string | Source image as a base64-encoded string (JSON body). |
image_url | string | Source image URL to fetch (JSON body). |
width | integer | Target width in px (≤8000). If only one dimension is given, the other is derived from the aspect ratio. |
height | integer | Target height in px (≤8000). |
algorithm | string | Resampling kernel: nearest · bilinear · bicubic (default) · lanczos. |
crop_mode | string | What happens when the target aspect differs: pad (default — fit inside, pad the rest), fill (cover + crop at gravity), stretch (distort). |
pad_color | string | Padding / JPEG-flatten color: transparent (default) · white · black. |
gravity | string | Crop anchor for crop_mode=fill and the custom crop: center (default) · top · bottom · left · right · attention (auto-detects the most salient region). |
crop_width | integer | Custom crop: cut an exact crop_width×crop_height region at gravity before any resize. Both must be given; the region is clamped to the image bounds. Positional gravities are pixel-exact (no resampling). |
crop_height | integer | See crop_width. |
format | string | Output format: keep (default) · jpeg · png · webp · avif · tiff · ico. |
quality | integer | 1–100 (default 90). Applies to lossy formats (JPEG/WebP/AVIF/TIFF). |
target_kb | integer | Best-effort maximum output size in KB. The server re-encodes at decreasing quality (up to 6 iterations) until the result fits. Lossy formats only; ignored for PNG/ICO. The floor is quality 1 — a tiny budget on a huge image may still come out over. |
keep_metadata | boolean | true keeps EXIF/ICC/XMP metadata in the output. Default false — metadata is stripped (orientation is applied first either way). |
vignette | number | 0–100 radial darkening (default 0). |
sharpen | number | 0–200 unsharp-mask strength (default 0). |
grayscale | boolean | Convert to grayscale (default false). |
brightness | number | −100…100 (default 0). |
contrast | number | −100…100 (default 0). |
Request headers
| Header | Description |
|---|---|
X-Api-Key | Your API key (rs_live_…). Also accepted as Authorization: Bearer …. |
Accept | application/json to receive base64 + dimensions instead of binary. |
Idempotency-Key | Optional. Retries with the same key return the original response and are never double-charged. |
Responses
| Code | Description |
|---|---|
200 | Image optimized. Binary image (or JSON when Accept: application/json). Response headers include X-Bytes-In/X-Bytes-Out, X-Width/X-Height, credit and rate-limit headers. |
400 | Invalid parameters or unprocessable input (no credits charged). Envelope: { "error": { "code", "message" } }. |
401 | Authentication failed — missing or invalid API key. |
402 | Insufficient credits (only possible when a non-zero cost is configured). |
413 | Upload over 50 MB or input over 64 megapixels. |
429 | Rate limit exceeded (no credits charged). Includes a Retry-After header. |
Response headers
| Header | Description |
|---|---|
X-Width / X-Height | Dimensions of the result image. |
X-Bytes-In / X-Bytes-Out | Input and output sizes — your compression receipt. |
X-Credits-Charged | Credits charged for this call (0 by default). |
X-Credits-Remaining | Remaining wallet balance after the call. |
X-RateLimit-Remaining | Requests remaining in the current window. |
Account endpoint
GET /api/v1/account
Fetch the current credit balance for the authenticated key. Balance changes may lag a few seconds; to track locally, read this once and then adjust using the X-Credits-Charged header returned by each call.
{
"data": {
"credits": { "balance": 200 }
}
}