Editor API
Crop, fit, backgrounds, text and picture layers; render a preview of any format.
From 1.1.0-rc.6. https://imgcompress.example.com stands for your instance.
Crop, fit, backgrounds, text and picture layers; render a preview of any format.
From 1.1.0-rc.6. https://imgcompress.example.com stands for your instance.
Render any supported input as PNG
Needs the API key when PUBLIC_API_KEY is set. Operation ID: preview.
When: Use to show or crop any input (PSD, HEIC, RAW and more) as PNG before editing. Nothing to call before.
Decodes PSD, HEIC, RAW, SVG, EPS and the rest into a PNG, e.g. to show or crop it in an app. X-Image-Width/X-Image-Height give the original size. Formats in preview_unsupported_formats answer 415.
bashcurl -fsS https://imgcompress.example.com/api/v1/preview \ -H "Authorization: Bearer $PUBLIC_API_KEY" \ -F "file=@design.psd" -o design.png
multipart/form-data, required.
| Field | Type | Required | Description |
|---|---|---|---|
file | file | yes | The image to render. |
| Status | Meaning | Content |
|---|---|---|
| 200 | PNG of the image. | image/png. Headers: X-Image-Width, X-Image-Height |
| 400 | Invalid options or form. message says which field and what is allowed. | application/json |
| 401 | PUBLIC_API_KEY is set and the request is neither from the web UI nor carries the key. | application/json |
| 403 | A browser on another website sent this while ENABLE_PUBLIC_API is off, or the feature is turned off on this container (storage management). | application/json |
| 413 | The request is larger than MAX_UPLOAD_SIZE_MB. Nothing was stored. | application/json |
| 415 | A file type the container cannot read. GET /formats lists supported_formats. | application/json |
Crop, fit to size, add backgrounds, text and picture layers
Needs the API key when PUBLIC_API_KEY is set. Operation ID: edit.
When: Use to crop or fit one image, with backgrounds, text and picture layers. Pictures for layers come from POST /editor/assets first.
Everything the web UI editor does, for one image. Send the image as file and the output size as fit_width and fit_height.
render=true: answers with the finished PNG at full size.crop (the selection in source pixels, e.g. what auto-crop picked) and a preview PNG as data URL, longest side at most 2048 px. preview=false leaves the preview out.Picture layers and a stored background need an editor session: upload each picture once with POST /editor/assets and pass fit_session plus the asset ids. A one-off background can also be sent directly as fit_background. Up to 5 picture layers.
To get another format, send the PNG to POST /convert.
bash# Instagram square with a blurred background and a caption curl -fsS https://imgcompress.example.com/api/v1/edit \ -H "Authorization: Bearer $PUBLIC_API_KEY" \ -F "file=@photo.jpg" -F fit_width=1080 -F fit_height=1080 -F fit_mode=blur \ -F 'fit_text={"text":"Summer","size":0.1,"y":0.88}' -F render=true -o square.png
multipart/form-data, required.
| Field | Type | Required | Description |
|---|---|---|---|
file | file | yes | The image to edit. |
fit_background | file | no | Background picture for fit_mode=image, without a session. |
render | boolean | no | true: answer with the full-size PNG instead of JSON. If omitted: off (JSON). |
preview | boolean | no | JSON answer only: include the preview image. If omitted: true. |
fit_width | integer | yes | Output width in pixels. Range: 1 to 8192. Recommended: 1080. Required. |
fit_height | integer | yes | Output height in pixels. Range: 1 to 8192. Recommended: 1080. Required. |
fit_mode | string | no | crop fills the frame; the others fit the image on a blurred, solid, transparent or picture background. Values: crop, blur, solid, transparent, image. If omitted: crop. |
crop_x | integer | no | Selection in source pixels: left edge. Give all four crop_* or none. Min: 0. If omitted: not applied. |
crop_y | integer | no | Selection in source pixels: top edge. Min: 0. If omitted: not applied. |
crop_width | integer | no | Selection in source pixels: width. Min: 1. If omitted: not applied. |
crop_height | integer | no | Selection in source pixels: height. Min: 1. If omitted: not applied. |
fit_scale | number | no | Image size on the canvas; 1 is the largest size that still fits. Range: 0.01 to 20. If omitted: not applied. |
fit_x | number | no | Image centre as a share of the canvas width (0.5 = centred). Needs fit_y. Range: -1 to 2. If omitted: not applied. |
fit_y | number | no | Image centre as a share of the canvas height (0.5 = centred). Needs fit_x. Range: -1 to 2. If omitted: not applied. |
fit_rotation | number | no | Image rotation in degrees, clockwise. If omitted: not applied. |
fit_color | string | no | Solid background colour (hex), or the start of a gradient. If omitted: not applied. |
fit_color_to | string | no | End colour: turns the solid background into a linear gradient. If omitted: not applied. |
fit_gradient_angle | number | no | Gradient angle in degrees, like CSS (180 = top to bottom). If omitted: not applied. |
fit_pattern | string | no | Pattern over a solid background. Values: none, checker, dots, stripes, grid. If omitted: none. |
fit_dim | number | no | Darken the background (blur, solid, image). Range: 0 to 0.9. If omitted: not applied. |
fit_blur | number | no | Blur strength (blur, image). Range: 0 to 1. If omitted: not applied. |
fit_tint | number | no | Tint opacity over the background (blur, solid, image). Range: 0 to 1. If omitted: not applied. |
fit_tint_color | string | no | Tint colour (opaque hex). If omitted: not applied. |
fit_tint_color_to | string | no | Tint end colour, for a gradient tint. If omitted: not applied. |
fit_tint_angle | number | no | Tint gradient angle in degrees. If omitted: not applied. |
fit_bg_scale | number | no | Background picture zoom (fit mode image). Range: 0.1 to 10. If omitted: not applied. |
fit_bg_x | number | no | Background picture centre, share of the width (fit mode image). If omitted: not applied. |
fit_bg_y | number | no | Background picture centre, share of the height (fit mode image). If omitted: not applied. |
fit_bg_rotation | number | no | Background picture rotation in degrees (fit mode image). If omitted: not applied. |
fit_text | string | no | One text as JSON: text (max 200 chars), font_id (inter, noto-serif, jetbrains-mono, caveat), bold, italic, size (share of the height), color, opacity, x, y (0..1), shadow, align (left, center, right), rotation. If omitted: not applied. |
fit_layers | string | no | Layers as a JSON list, bottom first: up to 5 text layers ({"type":"text"} plus the keys of fit_text) and up to 5 picture layers ({"type":"image","asset":"<id from /editor/assets>","x","y","width","height","rotation","opacity"}). Picture layers need fit_session. If omitted: not applied. |
fit_session | string | no | Editor session from POST /editor/assets, for picture layers or a stored background. If omitted: not applied. |
fit_background_asset | string | no | Background picture id from POST /editor/assets (fit mode image). If omitted: not applied. |
| Status | Meaning | Content |
|---|---|---|
| 200 | PNG with render=true, else the selection and a preview. | image/png, application/json |
| 400 | Invalid options or form. message says which field and what is allowed. | application/json |
| 401 | PUBLIC_API_KEY is set and the request is neither from the web UI nor carries the key. | application/json |
| 403 | A browser on another website sent this while ENABLE_PUBLIC_API is off, or the feature is turned off on this container (storage management). | application/json |
| 410 | The editor session expired; upload the pictures again with a new session. | application/json |
| 413 | The request is larger than MAX_UPLOAD_SIZE_MB. Nothing was stored. | application/json |
EditResult)#| Field | Type | Required | Description |
|---|---|---|---|
crop | object | yes | |
crop.x | integer | yes | |
crop.y | integer | yes | |
crop.width | integer | yes | |
crop.height | integer | yes | |
crop.originalWidth | integer | no | |
crop.originalHeight | integer | no | |
crop.fit | object | no | |
preview | string | no | PNG as a data URL (data:image/png;base64, then the image). |
Store a picture for layers or backgrounds
Needs the API key when PUBLIC_API_KEY is set. Operation ID: uploadEditorAsset.
When: Call before POST /edit when you use picture layers or a stored background: keep session and asset.
Stores the picture once for an editor session, so POST /edit can use it many times by id. Without session a new session starts. Sessions are private (random ids, never listed) and expire with the other temporary files. 409: session full; 410: session expired, start a new one.
multipart/form-data, required.
| Field | Type | Required | Description |
|---|---|---|---|
file | file | yes | The picture. |
session | string | no | Session from an earlier upload. If omitted: a new session. |
| Status | Meaning | Content |
|---|---|---|
| 200 | Stored. | application/json |
| 400 | Invalid options or form. message says which field and what is allowed. | application/json |
| 401 | PUBLIC_API_KEY is set and the request is neither from the web UI nor carries the key. | application/json |
| 403 | A browser on another website sent this while ENABLE_PUBLIC_API is off, or the feature is turned off on this container (storage management). | application/json |
| 409 | Conflicts with the current state (see message). | application/json |
| 410 | The editor session expired; upload the pictures again with a new session. | application/json |
| 413 | The request is larger than MAX_UPLOAD_SIZE_MB. Nothing was stored. | application/json |
EditorAsset)#| Field | Type | Required | Description |
|---|---|---|---|
session | string | yes | Pass as fit_session (and session for more uploads). Pattern: ^[A-Za-z0-9_-]{32}$. |
asset | string | yes | Use in fit_layers or fit_background_asset. Pattern: ^[A-Za-z0-9_-]{22}$. |
width | integer | yes | |
height | integer | yes |