> For the complete documentation index, see [llms.txt](https://docs.scaleflex.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scaleflex.com/dynamic-media-optimization-dmo/transformations/image-optimization/operations/crop/face-crop.md).

# Face Crop

Crop operation focusing only on one face

Finds the most prominent face in the image and crops it to specified dimension provided with the **width** and **height** parameters. If you however provide only one dimension, the other dimension will be chosen automatically to keep the aspect ratio of the face.

<mark style="color:orange;">**func=face**</mark>

{% hint style="info" %}
If there is no face in the image or many faces are found, the operation defaults to a standard crop.
{% endhint %}

## Examples

| Preview                                                                                                                                                                                                             | Syntax                                                                                                                                                                                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FAy6bEVwUaCE5aOPgUEhl%2Fimage.png?alt=media\&token=f28e75a2-63c2-4626-ab11-844628e40698) | <p>Standard crop:<br><a href="https://fdocs.filerobot.com/docs/business-portfolio.jpg?w=400&#x26;h=300">/docs/business-portfolio.jpg?<mark style="color:orange;"><strong>w=400</strong></mark>&<mark style="color:orange;"><strong>h=300</strong></mark></a></p>                                                                          |
| ![](https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FNssPK5UuZD7xYIN9gbF1%2Fimage.png?alt=media\&token=751c42c5-d8f6-4e08-a623-7b2d8cc138c8) | <p>Face crop:<br><a href="https://fdocs.filerobot.com/docs/business-portfolio.jpg?w=400&#x26;h=300&#x26;func=face">/docs/business-portfolio.jpg?<mark style="color:orange;"><strong>w=400</strong></mark>&<mark style="color:orange;"><strong>h=300</strong></mark>&<mark style="color:orange;"><strong>func=face</strong></mark></a></p> |
| ![](https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2F78bbqMVHrDznhKvyYM8x%2Fimage.png?alt=media\&token=6423ee30-6a54-45d0-bdf4-ab7b49b4fa8a) | <p>Face crop:<br><a href="https://fdocs.filerobot.com/docs/classroom.jpg?h=240&#x26;w=380&#x26;func=face">/docs/classroom.jpg?<mark style="color:orange;"><strong>h=240</strong></mark>&<mark style="color:orange;"><strong>w=380</strong></mark>&<mark style="color:orange;"><strong>func=face</strong></mark></a></p>                   |
| ![](https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2Fh1YvcXrpyQitHUlAfULN%2Fimage.png?alt=media\&token=16aaa397-b8d7-4631-aa2b-85a08e906e13) | <p>Face crop with automatic aspect ratio:<br><a href="https://fdocs.filerobot.com/docs/classroom.jpg?h=240&#x26;func=face">/docs/classroom.jpg?<mark style="color:orange;"><strong>h=240</strong></mark>&<mark style="color:orange;"><strong>func=face</strong></mark></a></p>                                                            |

## Face margin

Sets margins around the face. You can set equal margins with **face\_margin=X** or separate horizontal and vertical margins (**face\_margin=W,H**).

<mark style="color:orange;">**face\_margin=X|W,H**</mark>

### Examples

| Preview                                                                                                                                                                                                             | Syntax                                                                                                                                                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FWkoVHhUfsC4RDIdOEUS7%2Fimage.png?alt=media\&token=0b9f4d6c-862d-467f-aa25-75928ad3f74a) | [/docs/business-portfolio.jpg?<mark style="color:orange;">**w=400**</mark>&<mark style="color:orange;">**h=300**</mark>&<mark style="color:orange;">**func=face**</mark>&<mark style="color:orange;">**face\_margin=60**</mark>](https://fdocs.filerobot.com/docs/business-portfolio.jpg?w=400\&h=300\&func=face\&face_margin=60) |
| ![](https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FV0SmxIKMrHecvFY6pgXd%2Fimage.png?alt=media\&token=557fcb92-79c2-4d96-9376-174d47c6e5db) | [/docs/classroom.jpg?<mark style="color:orange;">**h=240**</mark>&<mark style="color:orange;">**func=face**</mark>&<mark style="color:orange;">**face\_margin=80,30**</mark>](https://fdocs.filerobot.com/docs/classroom.jpg?h=240\&func=face\&face_margin=80,30)                                                                 |
