---
title: Fit
summary: The fit parameter controls how the image will be constrained within the provided size (width and height) values, in order to maintain the correct proportions.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/image_optimizer/enum.Fit/
---

**Kind:** Enum  
**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#492

```rust
pub enum Fit {
    Bounds = 1,
    Cover = 2,
    Crop = 3,
}
```

The fit parameter controls how the image will be constrained within
the provided size (width and height) values, in order to maintain
the correct proportions.

## Variants

### Bounds

**Value:** `1`

Resize the image to fit entirely within the specified region, making
one dimension smaller if needed.

### Cover

**Value:** `2`

Resize the image to entirely cover the specified region, making one
dimension larger if needed.

### Crop

**Value:** `3`

Resize and crop the image centrally to exactly fit the specified region.

## Trait implementations

### impl Clone for Fit

#### clone

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

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

**Parameters**

- `self`: `&Self`

**Returns**

`Self`

### impl Debug for Fit

#### fmt

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

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

**Parameters**

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

**Returns**

`$crate::fmt::Result`

### impl Serialize for Fit

#### serialize

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

```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>`
