Media CDN
The ENAD Media CDN for serving product and brand assets at https://media.enad.io.
Domain: https://media.enad.io
Overview
The Media CDN provides image processing capabilities including resizing, cropping, format conversion, and various transformation effects.
Endpoints
Image Processing
GET /{app_id}/{filename}
Process and transform images stored in R2 bucket with various options.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
app_id |
string |
Yes | Application/tenant UUID identifier |
filename |
string |
Yes | Image filename in the bucket |
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
width |
u32 |
No | - | Target width in pixels (1-5000) |
height |
u32 |
No | - | Target height in pixels (1-5000) |
quality |
u8 |
No | 80 |
Image quality (0-100) |
format |
string |
No | original | Output format: webp, avif, png, jpeg, jpg |
fit |
string |
No | contain |
Resize mode (see Fit Modes below) |
blur |
f32 |
No | - | Blur intensity (0.0-100.0) |
crop_x |
i32 |
No | - | Horizontal crop offset in pixels |
crop_y |
i32 |
No | - | Vertical crop offset in pixels |
fill |
string |
No | - | Background fill color (hex format: #000000) |
bg_remove |
boolean |
No | - | Remove background using machine learning |
Fit Modes
contain- Resize to fit within dimensions, maintaining aspect ratiocover- Scale to fill dimensions, cropping excess (centers crop unlesscrop_x/crop_yspecified)scale-down- Only resize if image is larger than target dimensionscrop- Scale and crop to exact dimensionspad- Resize to fit and pad remaining space with transparent backgroundsqueeze- Stretch/squash to exact dimensions, ignoring aspect ratio
Dimension Behavior
- If only
widthis provided: height is calculated to maintain aspect ratio - If only
heightis provided: width is calculated to maintain aspect ratio - If both are provided: behavior depends on
fitmode - If neither is provided: original dimensions are used
Examples
# Resize to width 800, maintain aspect ratio
GET https://media.enad.io/{app_id}/photo.jpg?width=800
# Convert to WebP with quality 90
GET https://media.enad.io/{app_id}/photo.jpg?format=webp&quality=90
# Resize and crop to exact dimensions
GET https://media.enad.io/{app_id}/photo.jpg?width=1920&height=1080&fit=cover
# Add blur effect
GET https://media.enad.io/{app_id}/photo.jpg?width=800&blur=5.0
# Fill transparent areas with white
GET https://media.enad.io/{app_id}/photo.png?fill=%23FFFFFF
# Custom crop position
GET https://media.enad.io/{app_id}/photo.jpg?width=500&height=500&fit=cover&crop_x=100&crop_y=50
Response
- Content-Type: Varies based on output format
image/pngimage/jpegimage/webpimage/avif
- Status Codes:
200 OK- Success400 Bad Request- Invalid parameters404 Not Found- Image not found500 Internal Server Error- Processing error
Limits
- Dimensions: Maximum 5000x5000 pixels
- Minimum Dimensions: At least 1 pixel
- Image Quality: 0-100
- Blur Range: 0.0-100.0
- URL: Maximum 16 KB (typical HTTP limit)
Error Responses
All errors return appropriate HTTP status codes with descriptive messages:
400 Bad Request
Returned when:
- Invalid dimensions (outside 1-5000 range)
- Invalid fit mode for given dimensions
- Invalid format specified
- Invalid hex color format
- Invalid blur value
- Crop offsets exceed image bounds
404 Not Found
Returned when:
- Requested image file doesn’t exist in bucket
500 Internal Server Error
Returned when:
- Image processing fails
- Internal Server Error