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

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
