---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---

# `CropMode`

Enumerator options for [`imageOptimizerOptions.crop.mode`](./imageOptimizerOptions.mdx) and `imageOptimizerOptions.precrop.mode`.

## Constants

- `Smart` (`"smart"`) Enables 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.
- `Safe` (`"safe"`)	Allow cropping out-of-bounds regions.

## Examples

```js
import { CropMode, Region } from 'fastly:image-optimizer';

addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));

async function handleRequest(event) {
  return await fetch('https://www.w3.org/Graphics/PNG/text2.png', {
    imageOptimizerOptions: {
      region: Region.UsEast,
      crop: {
        size: { ratio: { width: 4, height: 3 } },
        mode: CropMode.Smart,
      }
    },
    backend: 'w3'
  });
}
```