> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enad.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Proxy CDN

Domain: `https://image-proxy.enad.io`

## Overview

The Image Proxy API allows you to fetch images from external URLs, process them (resize, crop, format conversion), cache them in R2, and serve the optimized result.

## Endpoints

### Proxy Image Processing

**GET** `/{app_id}`

Fetch an image from a source URL, process it, store it, and return the result.

#### Path Parameters

| Parameter | Type     | Required | Description                                                               |
| --------- | -------- | -------- | ------------------------------------------------------------------------- |
| `app_id`  | `string` | Yes      | Application/tenant UUID identifier used for namespacing the cached images |

#### Query Parameters

| Parameter   | Type      | Required | Default   | Description                                         |
| ----------- | --------- | -------- | --------- | --------------------------------------------------- |
| `src`       | `string`  | Yes      | -         | The absolute URL of the source image to fetch       |
| `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 ratio
* **`cover`** - Scale to fill dimensions, cropping excess (centers crop unless `crop_x`/`crop_y` specified)
* **`scale-down`** - Only resize if image is larger than target dimensions
* **`crop`** - Scale and crop to exact dimensions
* **`pad`** - Resize to fit and pad remaining space with transparent background
* **`squeeze`** - Stretch/squash to exact dimensions, ignoring aspect ratio

#### Dimension Behavior

* If only `width` is provided: height is calculated to maintain aspect ratio
* If only `height` is provided: width is calculated to maintain aspect ratio
* If both are provided: behavior depends on `fit` mode
* If neither is provided: original dimensions are used

#### Examples

```bash theme={null}
# Proxy and resize external image to width 800
GET https://image-proxy.enad.io/{app_id}?src=https://example.com/image.jpg&width=800

# Proxy, convert to WebP, and set quality
GET https://image-proxy.enad.io/{app_id}?src=https://example.com/image.jpg&format=webp&quality=90

# Proxy and crop to exact dimensions
GET https://image-proxy.enad.io/{app_id}?src=https://example.com/image.jpg&width=1920&height=1080&fit=cover

# Proxy with blur effect
GET https://image-proxy.enad.io/{app_id}?src=https://example.com/image.jpg&width=800&blur=5.0
```

#### Response

* **Content-Type**: Varies based on output format (e.g., `image/jpeg`, `image/webp`)
* **Status Codes**:
  * `200 OK` - Success
  * `400 Bad Request` - Invalid parameters or failed to fetch source image
  * `500 Internal Server Error` - Processing or storage error

## Limits

* **Dimensions**: Maximum 5000x5000 pixels
* **Minimum Dimensions**: At least 1 pixel
* **Image Quality**: 0-100
* **Blur Range**: 0.0-100.0
* **URL**: Must be a valid HTTP/HTTPS URL passed in `src`
