---
title: ImageOptimizerOptions
summary: ImageOptimizerOptions contains options that correspond to the public API.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/image_optimizer/struct.ImageOptimizerOptions/
---

**Kind:** Struct  
**Module:** [image_optimizer](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/image_optimizer/)  
**Package:** fastly 0.13.1  
**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/image_optimizer.rs#672

```rust
#[non_exhaustive]
pub struct ImageOptimizerOptions {
    pub region: Option<ImageOptimizerRegion>,
    pub preserve_query_string_on_origin_request: Option<bool>,
    pub allow_malformed_query_params: Option<bool>,
    pub auto: Option<Auto>,
    pub bg_color: Option<HexColor>,
    pub blur: Option<BlurMode>,
    pub brightness: Option<i32>,
    pub bw: Option<BWMode>,
    pub canvas: Option<Canvas>,
    pub contrast: Option<i32>,
    pub crop: Option<Crop>,
    pub dpr: Option<f32>,
    pub enable: Option<EnableOpt>,
    pub fit: Option<Fit>,
    pub format: Option<Format>,
    pub frame: Option<u32>,
    pub height: Option<PixelsOrPercentage>,
    pub level: Option<Level>,
    pub metadata: Option<Metadata>,
    pub optimize: Option<OptimizeLevel>,
    pub orient: Option<Orientation>,
    pub pad: Option<Sides>,
    pub precrop: Option<Crop>,
    pub profile: Option<Profile>,
    pub quality: Option<u32>,
    pub resize_filter: Option<ResizeAlgorithm>,
    pub saturation: Option<i32>,
    pub sharpen: Option<Sharpen>,
    pub trim: Option<Sides>,
    pub trim_color: Option<TrimColor>,
    pub width: Option<PixelsOrPercentage>,
}
```

ImageOptimizerOptions contains options that correspond to the [public API](https://www.fastly.com/documentation/reference/io/).

## Fields

### region

**Type:** `Option<ImageOptimizerRegion>`

Indicates where image transformations will occur. Must be set.

See [`ImageOptimizerRegion`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/image_optimizer/enum.ImageOptimizerRegion/) for available options. The chosen region should be close to
your origin.

### preserve_query_string_on_origin_request

**Type:** `Option<bool>`

If true, preserves query parameters not belonging to the
Image Optimizer API when requesting the origin image.

### allow_malformed_query_params

**Type:** `Option<bool>`

If true, ignores malformed and duplicate query parameters and returns a
response header, `Fastly-Io-Compute-Warnings`, containing a comma
separated list of errors (if there are any).

By default IO on compute is strict when parsing query parameters, and
passing an invalid or malformed value produces an HTTP 400 response.
This behavior is different than IO running in VCL services where most
errors fail silently. Setting this parameter to `true` should make the
behavior more in line with VCL services.

### auto

**Type:** `Option<Auto>`

Requests an output format based on the `Accept` header.

### bg_color

**Type:** `Option<HexColor>`

Sets a background color when replacing transparent pixels
or with `pad` or `canvas`.

### blur

**Type:** `Option<BlurMode>`

Blurs the image.

### brightness

**Type:** `Option<i32>`

Adjusts image brightness.

### bw

**Type:** `Option<BWMode>`

Converts image to black and white duotone.

### canvas

**Type:** `Option<Canvas>`

Adds a canvas surrounding the image.

### contrast

**Type:** `Option<i32>`

Adjusts image contrast.

### crop

**Type:** `Option<Crop>`

Crops the image.

### dpr

**Type:** `Option<f32>`

Ratio between physical and logical pixels, a float between 0-10.

Adjusts any resize requests according to this ratio.

### enable

**Type:** `Option<EnableOpt>`

Allows for various image transformations to occur,
particularly upscaling images.

### fit

**Type:** `Option<Fit>`

Describes how the image should fit within the requested dimensions.

### format

**Type:** `Option<Format>`

Re-encodes the image to a given output format.

### frame

**Type:** `Option<u32>`

Request a single frame for an animated image.

Currently only supported for animated GIFs.

### height

**Type:** `Option<PixelsOrPercentage>`

Adjusts image height.

### level

**Type:** `Option<Level>`

For use with GIF to MP4 conversions.

See <https://www.fastly.com/documentation/reference/io/level/> for detailed information.

### metadata

**Type:** `Option<Metadata>`

Preserves metadata on the input image.

### optimize

**Type:** `Option<OptimizeLevel>`

Attempts to select an output quality to optimize the image.

### orient

**Type:** `Option<Orientation>`

Controls how the image will be oriented.

### pad

**Type:** `Option<Sides>`

Adds pixels surrounding the image.

### precrop

**Type:** `Option<Crop>`

Applies the crop instruction before all other parameters.

### profile

**Type:** `Option<Profile>`

For use with GIF to MP4 conversions.

See <https://www.fastly.com/documentation/reference/io/level/> for detailed information.

### quality

**Type:** `Option<u32>`

Request an output quality.

### resize_filter

**Type:** `Option<ResizeAlgorithm>`

Specify which algorithm to use when resizing an image.

### saturation

**Type:** `Option<i32>`

Adjust image saturation.

### sharpen

**Type:** `Option<Sharpen>`

Applies an unsharp mask to the image.

### trim

**Type:** `Option<Sides>`

Removes pixels from the image on all sides.

### trim_color

**Type:** `Option<TrimColor>`

Trims the image on all sides based on a given color.

### width

**Type:** `Option<PixelsOrPercentage>`

Adjusts image width.

## Methods

### from_region

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/image_optimizer.rs#767

```rust
fn from_region(region: ImageOptimizerRegion) -> Self
```

Create ImageOptimizerOptions for the specified region. It is recommended to pick
a region closest to your origin that serves images.

See [`Request::set_image_optimizer`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_image_optimizer) for example usage.

**Parameters**

- `region`: `ImageOptimizerRegion`

**Returns**

`Self`

## Trait implementations

### impl Clone for ImageOptimizerOptions

#### clone

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/image_optimizer.rs#670

```rust
fn clone(&self) -> Self
```

**Parameters**

- `self`: `&Self`

**Returns**

`Self`

### impl Debug for ImageOptimizerOptions

#### fmt

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/image_optimizer.rs#670

```rust
fn fmt(&self, f: &mut Formatter<'_>) -> Result
```

**Parameters**

- `self`: `&Self`
- `f`: `&mut $crate::fmt::Formatter`

**Returns**

`$crate::fmt::Result`

### impl Default for ImageOptimizerOptions

#### default

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/image_optimizer.rs#670

```rust
fn default() -> Self
```

**Returns**

`Self`

### impl Serialize for ImageOptimizerOptions

#### serialize

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/image_optimizer.rs#670

```rust
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where
    __S: Serializer,
```

**Parameters**

- `self`: `&Self`
- `__serializer`: `__S`

**Returns**

`_serde::__private228::Result<__S::Ok, __S::Error>`

## Auto trait implementations

- `Freeze`
- `RefUnwindSafe`
- `Send`
- `Sync`
- `Unpin`
- `UnsafeUnpin`
- `UnwindSafe`

## Blanket implementations

- `Any`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Downcast`
- `DowncastSync`
- `ErasedDestructor`
- `From<T>`
- `Into<U>`
- `IntoEither`
- `Same`
- `ToOwned`
- `TryFrom<U>`
- `TryInto<U>`
