---
title: CropMode
summary: Controls cropping behaviour.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/image_optimizer/enum.CropMode/
---

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

```rust
pub enum CropMode {
    Safe = 1,
    Smart = 2,
}
```

Controls cropping behaviour.

## Variants

### Safe

**Value:** `1`

Avoid invalid parameter errors and return an image.

By default, if the specified cropped region is outside the bounds of the image, then the
transformation will fail with the error "Invalid transformation for requested image:
Invalid crop, region out of bounds". This option will instead deliver the image as an
intersection of the origin image and the specified cropped region. This avoids the error,
but the resulting image may not be of the specified dimensions.

### Smart

**Value:** `2`

Enable content-aware algorithms to attempt to crop the image to the desired aspect ratio
while intelligently focusing on the most important visual content, including the detection
of faces.

## Trait implementations

### impl Clone for CropMode

#### clone

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

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

**Parameters**

- `self`: `&Self`

**Returns**

`Self`

### impl Debug for CropMode

#### fmt

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

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

**Parameters**

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

**Returns**

`$crate::fmt::Result`

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