# Resize and convert images with Cloudflare

> Serve resized, cropped and converted images in IXO client apps with Cloudflare Image transformations on ixo.world: URL format, parameters and limits.

IXO client applications serve images through Cloudflare Image transformations on the ixo.world
domain. Instead of storing several sizes of each image, you write the size, crop, quality and format
into the image URL, and the image is transformed when it is requested. Use this page to build those
URLs: the format, the parameters, responsive images, the limits and what to check when an image
does not load.

## Configuration

| Setting | Value |
| --- | --- |
| Domain | ixo.world |
| Allowed origins | ipfs.gateway.ixo.world |

## Build an image URL

Transform an image with this URL format:

```bash
https://ixo.world/cdn-cgi/image/[OPTIONS]/[SOURCE-IMAGE-CID]
```

For example, an image 300 pixels wide at quality 80:

```bash
https://ixo.world/cdn-cgi/image/width=300,quality=80/[SOURCE-IMAGE-CID]
```

## Responsive images

### Using width=auto

`width=auto` picks the image size that suits the device:

```bash
https://ixo.world/cdn-cgi/image/width=auto/[SOURCE-IMAGE-CID]
```

| Size | Device |
| --- | --- |
| 320px | Mobile |
| 640px | Tablet |
| 960px | Laptop |
| 1920px | Desktop |

### Using srcset (recommended)

```html
<img
  srcset="
    https://ixo.world/cdn-cgi/image/width=640/[SOURCE-IMAGE-CID]   640w,
    https://ixo.world/cdn-cgi/image/width=960/[SOURCE-IMAGE-CID]   960w,
    https://ixo.world/cdn-cgi/image/width=1920/[SOURCE-IMAGE-CID] 1920w
  "
  sizes="(max-width: 767px) 640px,
         (max-width: 1023px) 960px,
         1920px"
  src="https://ixo.world/cdn-cgi/image/width=960/[SOURCE-IMAGE-CID]"
  alt="Responsive image"
/>
```

## Parameters

### Resizing

| Parameter | What it sets | Example |
| --- | --- | --- |
| `width` | Image width in pixels | `width=300` |
| `height` | Image height in pixels | `height=200` |
| `fit` | Resizing method | `fit=cover` |
| `gravity` | Focus point when cropping | `gravity=auto` |

### Fit options

| Value | What it does |
| --- | --- |
| `scale-down` | Resize to fit within the dimensions, never enlarge |
| `contain` | Resize to fit within the dimensions, preserving the aspect ratio |
| `cover` | Resize and crop to fill the dimensions |
| `crop` | Crop without scaling |
| `pad` | Resize and add padding to match the dimensions |

### Quality and format

| Parameter | What it sets | Example |
| --- | --- | --- |
| `quality` | JPEG/WebP quality (1-100) | `quality=80` |
| `format` | Output image format | `format=auto` |
| `sharpen` | Sharpen level (0.0-10.0) | `sharpen=1.0` |

### Format options

| Value | What it returns |
| --- | --- |
| `auto` | The best format for the browser |
| `webp` | WebP format |
| `avif` | AVIF format |
| `json` | The image metadata |

## Limits

| Limit | Value |
| --- | --- |
| Maximum image area | 100 megapixels |
| Maximum GIF/WebP animation | 50 megapixels |
| Maximum file size | 70 MB |
| AVIF format | Limited to 1,600 pixels max |
| HEIC/HEIF formats | Not supported |

## Security

- Only images from the allowed origins can be transformed. The source image URL must be on an
  allowed origin.
- SVG files are sanitized automatically.

## Examples

### Thumbnail

```bash
https://ixo.world/cdn-cgi/image/width=150,height=150,fit=cover,gravity=auto/[SOURCE-IMAGE-CID]
```

### Responsive profile image

```bash
https://ixo.world/cdn-cgi/image/width=auto,fit=cover,gravity=auto/[SOURCE-IMAGE-CID]
```

### Optimized banner

```bash
https://ixo.world/cdn-cgi/image/width=1200,height=400,fit=cover,quality=80,format=auto/[SOURCE-IMAGE-CID]
```

### High-DPI image

```bash
https://ixo.world/cdn-cgi/image/width=600,dpr=2,quality=75/[SOURCE-IMAGE-CID]
```

## When an image does not load

1. Check that the source URL is on an allowed origin.
2. Check that the image exists at the source URL.
3. Check that the transformation parameters are formatted correctly.
4. Check that the image is within the limits.

## Next steps

<CardGroup cols={2}>
  <Card title="SDK patterns for entities, rooms and claims" icon="code" href="/guides/dev/examples">
    Illustrative TypeScript for the IXO MultiClient and Matrix Client SDKs.
  </Card>
  <Card title="Developer portal" icon="rocket" href="/developers">
    Every developer guide and reference, by task.
  </Card>
</CardGroup>
