# Face crop

Finds the most prominent face in the image and crops it to the specified with the **width** and **height** parameters dimensions. 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://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/v6JY1wjTWrPpWKHeHrLZ/image.png) | <p>Standard crop:<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/business-portfolio.jpg?w=400&#x26;h=300">/samples.scaleflex.com/business-portfolio.jpg?<mark style="color:orange;"><strong>w=400</strong></mark>&<mark style="color:orange;"><strong>h=300</strong></mark></a></p>                                                                          |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/kSrjAHlq0HEExLIUAW8r/image.png) | <p>Face crop:<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/business-portfolio.jpg?w=400&#x26;h=300&#x26;func=face">/samples.scaleflex.com/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://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/EA9t35bbxMdtMjKZ49Nz/image.png) | <p>Face crop:<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/classroom.jpg?h=240&#x26;w=380&#x26;func=face">/samples.scaleflex.com/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://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/8shEjoQHIkIBO3Vifs3t/image.png) | <p>Face crop with automatic aspect ratio:<br><a href="https://doc.cloudimg.io/https://samples.scaleflex.com/classroom.jpg?h=240&#x26;func=face">/samples.scaleflex.com/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://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/w5nrHVfVHj5qPj1m8Ubg/image.png) | [/samples.scaleflex.com/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://doc.cloudimg.io/https://samples.scaleflex.com/business-portfolio.jpg?w=400\&h=300\&func=face\&face_margin=60) |
| ![](https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/W7U7OpdXcvdatsI5oLQS/image.png) | [/samples.scaleflex.com/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://doc.cloudimg.io/https://samples.scaleflex.com/classroom.jpg?h=240\&func=face\&face_margin=80,30)                                                                 |
