> ## Documentation Index
> Fetch the complete documentation index at: https://bunnynet-cb9733c2-onclientmiddleware.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Formats

> Convert images between formats for optimal compatibility and compression

Convert images to modern, efficient formats for better compression and performance. Bunny Optimizer supports a wide range of input formats and can transcode to optimized output formats.

## Parameter

<ParamField query="format" type="string">
  Convert the image to a specific output format.

  **Accepted values:** `webp`, `jpeg`, `png`, `gif`, `avif`

  **Default:** Original format (or auto-optimized based on configuration)
</ParamField>

## How it works

Bunny Optimizer can automatically convert between image formats, enabling you to serve modern, efficient formats like WebP while accepting legacy formats as input.

When configured with automatic format optimization, Bunny Optimizer detects client browser capabilities and serves the most optimal format. Browsers that support WebP receive WebP images, while older browsers receive JPEG or PNG.

## Supported formats

### Input formats

Bunny Optimizer accepts the following input formats:

* **JPEG** - Standard compressed photo format
* **PNG** - Lossless format with transparency support
* **WebP** - Compressed format with transparency support
* **GIF** - Animation and simple graphics format
* **BMP** - Uncompressed bitmap image format
* **TIFF** - Flexible format for high-detail images
* **TGA** - Raster graphics image format
* **PBM** - Simple monochrome bitmap format
* **HEIC** *(Public Preview)* - Compressed photo format commonly used by Apple devices
* **HEIF** *(Public Preview)* - Image container with efficient compression
* **AVIF** *(Public Preview)* - Image format using AV1 compression

### Output formats

Bunny Optimizer can convert images to these output formats:

* **JPEG** - Best for photographs without transparency
* **PNG** - Best for graphics, logos, or images requiring transparency
* **WebP** - Modern format offering 25-35% better compression than JPEG
* **GIF** - Best for simple animations or limited-color graphics
* **AVIF** *(Public Preview)* - Next-generation format with better compression than WebP and excellent quality, but slower encoding and slightly less universal support

<Note>
  WebP output is limited to a maximum dimension of 16,383 pixels on either width
  or height.
</Note>

<Note>
  Bunny optimizer limits AVIF output to a maximum area of 4 megapixels. Because AVIF encoding time grows with image area,
  the Optimizer favours lower latency and automatically falls back to another format (WebP, JPEG, or GIF) for larger images.

  For most on-the-fly optimisation use cases, we recommend WebP as the best overall balance between compression, image quality,
  browser compatibility, and processing performance. AVIF can offer excellent compression, but is generally better suited for
  smaller images or workflows where the additional encoding time is acceptable.
</Note>

## Usage

### Format conversion

Convert images to different formats to optimize compression or ensure compatibility.

```bash Convert to WebP theme={null}
https://yourzone.b-cdn.net/image.jpg?format=webp
```

```bash Convert to PNG for transparency theme={null}
https://yourzone.b-cdn.net/image.jpg?format=png
```

```bash Convert to JPEG for smaller file size theme={null}
https://yourzone.b-cdn.net/image.png?format=jpeg
```

WebP typically offers 25-35% better compression than JPEG at equivalent quality levels, making it ideal for web delivery when browser support is available.
While AVIF can achieve excellent compression, WebP is generally recommended for on-the-fly optimisation because it provides the best overall balance between compression, quality, compatibility, and processing performance.

### Automatic format optimization

Configure Bunny Optimizer to automatically serve the best format based on client browser capabilities. Enable WebP in your Optimizer settings to allow automatic format selection.

When enabled:

* Browsers supporting WebP receive WebP images
* Older browsers receive JPEG or PNG fallbacks
* No code changes required on your end

This ensures optimal performance without requiring manual format detection or maintaining multiple URL variants.

<Note>
  When automatic format optimization is enabled, your image URLs will remain as
  their original file type (e.g., `.png` or `.jpg`). The actual format served is
  determined by the `content-type` HTTP header, which will show `image/webp`
  when WebP is delivered. This approach ensures compatibility with browsers that
  don't support WebP while making implementation easier.
</Note>

### Animation support

Bunny Optimizer supports manipulation of animated image formats:

* **WebP** (animated)
* **GIF** (animated)
* **PNG** (APNG format)

<Info>
  We do not support transcoding animations to AVIF. If the original image is already in AVIF format and remains
  unmodified, the animation will be preserved. However, if the image is altered or converted from another format,
  the animation will be lost.
</Info>

Apply transformations like resizing, cropping, and color adjustments to animated images. The animation frames are processed while maintaining timing and loop settings.

```bash Resize animated GIF theme={null}
https://yourzone.b-cdn.net/animation.gif?width=400
```

```bash Convert animated GIF to WebP theme={null}
https://yourzone.b-cdn.net/animation.gif?format=webp
```

## Common considerations

### Transparency handling

When converting from formats that support transparency (PNG, WebP, GIF, AVIF) to formats that don't (JPEG), all transparent areas become opaque with a white or black background.

If you need to preserve transparency, ensure your output format supports it:

* Use `format=png` or `format=webp` for transparent images
* Avoid `format=jpeg` when transparency is required

### WebP configuration

Images are only encoded as WebP when you have WebP enabled in your Bunny Optimizer settings.

To enable WebP output:

1. Navigate to your Pull Zone settings
2. Go to **Optimizer → Settings**
3. Enable WebP support

Without this configuration, `format=webp` requests may not produce WebP output.

### Format selection guidance

**Use JPEG when:**

* Serving photographs or complex images
* Transparency is not required
* Maximum browser compatibility is needed

**Use PNG when:**

* Images contain transparency
* Graphics, logos, or text require sharp edges
* Lossless compression is preferred

**Use WebP when:**

* You need smaller file sizes than JPEG
* Browser support for WebP is acceptable (most modern browsers)
* You want transparency with better compression than PNG

**Use GIF when:**

* Simple animations are required
* Limited color palettes are acceptable
* Legacy compatibility is essential

## Combining with other transformations

Format conversion works seamlessly with all other Bunny Optimizer parameters:

```bash Convert format and adjust quality theme={null}
https://yourzone.b-cdn.net/image.jpg?format=webp&quality=75
```

```bash Resize and convert format theme={null}
https://yourzone.b-cdn.net/image.png?width=800&format=jpeg
```

```bash Complete optimization with format conversion theme={null}
https://yourzone.b-cdn.net/image.jpg?width=1200&crop=800,600&format=webp&quality=80&sharpen=true
```

Combining format conversion with quality control and resizing creates an efficient optimization pipeline that reduces bandwidth while maintaining visual quality.
