# 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                                                                                                                                                                                                                                                                                                                                                                          |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](/files/PrW67NDRw7QsAm8v7YDR) | <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>                                                                          |
| ![](/files/KPkUyJXoNhNOLzR93KB2) | <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> |
| ![](/files/5L8TD42jDBbQmyqJpGuW) | <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>                   |
| ![](/files/8458hjSzzbIIOiHWt4kn) | <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                                                                                                                                                                                                                                                                                                                                                                  |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![](/files/dOPFoeFHMnkVuN8aiG3P) | [/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) |
| ![](/files/XyZCcx2CcSN6rNhucgq8) | [/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)                                                                 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudimage.io/transformations/image-operations/crop/face-crop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
