---
title: TrimColor
summary: Identify a rectangular border based on specified color and remove this border from the edges of an image.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/image_optimizer/struct.TrimColor/
---

**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#379

```rust
pub struct TrimColor {
    pub color: HexColor,
    pub threshold: f32,
}
```

Identify a rectangular border based on specified color and remove this
border from the edges of an image.

## Fields

### color

**Type:** `HexColor`

Indicates what color to trim off.

### threshold

**Type:** `f32`

An optional number between 0 and 1 indicating how different a color can
be from the given trim color and still be trimmed.

This can be used if the background that is being trimmed is not uniform
(all one color). Setting it to 1 will trim everything, as 1 is the
largest possible color difference.

## Trait implementations

### impl Clone for TrimColor

#### clone

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

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

**Parameters**

- `self`: `&Self`

**Returns**

`Self`

### impl Debug for TrimColor

#### fmt

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

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

**Parameters**

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

**Returns**

`$crate::fmt::Result`

### impl Serialize for TrimColor

#### serialize

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

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

**Parameters**

- `self`: `&Self`
- `serializer`: `S`

**Returns**

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