Transform Image
Send a GET request to this endpoint to transform an existing image with various options.
ℹ️
You will need to authenticate to use this API. See authentication.
ℹ️
This endpoint consumes 1 credit per successful image transformation.
Request
GET https://api.ojo.so/v1/transform/{options}/{sourceUrl}Parameters
| Parameter | Type | Description |
|---|---|---|
| options | string | Comma-separated list of transformation options |
| sourceUrl | string | URL-encoded source image URL to transform |
Available Transformation Options
| Option | Format | Description | Example |
|---|---|---|---|
| w | w-(pixels) | Set output width | w-800 |
| h | h-(pixels) | Set output height | h-600 |
| mw | mw-(pixels) | Set maximum width | mw-1200 |
| mh | mh-(pixels) | Set maximum height | mh-800 |
| minw | minw-(pixels) | Set minimum width | minw-400 |
| minh | minh-(pixels) | Set minimum height | minh-300 |
| ar | ar-(ratio) | Set aspect ratio (width:height) | ar-16:9 |
| fit | fit-(mode) | Fit mode (cover/contain/fill/inside/outside) | fit-cover |
| fmt | fmt-(format) | Output format (jpeg/png/webp/avif) | fmt-webp |
| q | q-(0-100) | Quality setting | q-80 |
| prog | prog-(bool) | Enable progressive encoding | prog-true |
| lossless | lossless-(bool) | Enable lossless compression | lossless-true |
| crop | crop-(mode) | Crop mode (entropy/attention/center) | crop-entropy |
| fx | fx-(float) | Focal point X coordinate | fx-0.5 |
| fy | fy-(float) | Focal point Y coordinate | fy-0.5 |
| bri | bri-(-100,100) | Adjust brightness | bri-10 |
| con | con-(-100,100) | Adjust contrast | con-15 |
| sat | sat-(-100,100) | Adjust saturation | sat-20 |
| hue | hue-(-360,360) | Adjust hue | hue-90 |
| gray | blur-(bool) | Apply grayscale | gray-true |
| gm | gm-(float) | Adjust gamma | gm-2.2 |
| blur | blur-(float) | Apply blur effect | blur-3.5 |
| sharpen | sharpen-(bool) | Apply sharpening | sharpen-true |
| rot | rot-(degrees) | Rotate image | rot-90 |
| flip | flip-(bool) | Flip image vertically | flip-true |
| flop | flop-(bool) | Flip image horizontally | flop-true |
| bg | bg-(hex color,mean) | Set provided or mean of provided image color as background color | bg-ffffff |
| meta | meta-(bool) | Preserve metadata | meta-true |
| strip | strip-(bool) | Strip metadata | strip-true |
| dpr | dpr-(float) | Device pixel ratio | dpr-2 |
| auto | auto-(options) | Automatic optimizations (format/compress/enhance) | auto-format|compress |
curl --request GET \
--url 'https://api.ojo.so/v1/transform/w-800,h-600,fmt-webp,q-80/https%3A%2F%2Fexample.com%2Fimage.jpg' \
--header 'Authorization: Bearer <API Key>'Response
The transformed image is returned directly in the response body with the appropriate Content-Type header.
Caching
By default, the transformed images are served with Cache-Control: public, max-age=86400 (1 day).
Examples
Here are some common transformation examples:
Resize to specific dimensions
/transform/w-800,h-600/https://example.com/image.jpgConvert to WebP with quality setting
/transform/fmt-webp,q-80/https://example.com/image.jpgCrop and resize maintaining aspect ratio
/transform/w-800,h-600,fit-cover,crop-entropy/https://example.com/image.jpgOptimize for web delivery
/transform/auto-format|compress,w-800/https://example.com/image.jpgApply image adjustments
/transform/bri-10,con-15,sat-20,hue-30,sharpen-true/https://example.com/image.jpgResponsive image with DPR
/transform/w-800,dpr-2,auto-format/https://example.com/image.jpg