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

# Gravity

gravity - g - g\_\<position value>

<table><thead><tr><th width="152.33333333333331">Value</th><th width="95">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>gravity value</strong></td><td>string</td><td><p><em>Default Value: <strong>center</strong></em></p><p>Value can be;</p><ul><li>t, tl, tr, b, bl, br, c, center</li><li>face</li><li>faces (for multiple faces)</li><li>&#x3C;objectname> (simple object name)</li></ul><p>Eg. g_tr, g_face, g_sheep, g_hairdrier<br><br><em>Required Parameters:</em><br><a href="/image-transform/transform-options/crop.md">crop</a></p></td></tr></tbody></table>

Creates a region to focus for. Every value of Gravity defines a region to focus on. In order for to Gravity parameter to work, the image must also have a [Crop](/image-transform/transform-options/crop.md) parameter (by default [c\_cover](/image-transform/transform-options/crop.md#cover-default-c_cover) is used).

## Locational

Uses locations to adjust the gravity of cropped images.

| Top: t            | Top-Left: tl    | Top-Right: tr    |
| ----------------- | --------------- | ---------------- |
| Bottom: b         | Bottom-Left: bl | Bottom-Right: br |
| Center: center, c |                 |                  |

<figure><img src="https://demo.imagemash.io/w_400,h_150,g_t/jeep.png" alt=""><figcaption><p><a href="https://demo.imagemash.io/w_400,h_150,g_t/jeep.png">https://demo.imagemash.io/w_400,h_150,g_t/jeep.png</a></p></figcaption></figure>

<figure><img src="https://demo.imagemash.io/w_400,h_150,g_b/jeep.png" alt=""><figcaption><p><a href="https://demo.imagemash.io/w_400,h_150,g_t/jeep.png">https://demo.imagemash.io/w_400,h_150,g_t/jeep.png</a></p></figcaption></figure>

## Face / Faces / Object Detection

AI-powered face and object detection. Creates a region to focus on faces or objects.

{% tabs %}
{% tab title="Original" %}

<figure><img src="https://demo.imagemash.io/w_300/woman.jpg" alt=""><figcaption><p>woman.jpg</p></figcaption></figure>

Original image

`https://demo.imagemash.io/woman.jpg`
{% endtab %}

{% tab title="Default" %}

<figure><img src="https://demo.imagemash.io/w_300,h_300/woman.jpg" alt=""><figcaption><p>w_300,h_300</p></figcaption></figure>

`https://demo.imagemash.io/w_300,h_300/woman.jpg`

Default position after cropping (Centered)

{% hint style="info" %}
Please note that when you provide both Height and Width, c\_cover is automatically inserted into your image. Since it is the default Crop type.\
You need to specify your Crop type if you need to use other types.

So the above example is actually:  `w_300,h_300,c_contain`
{% endhint %}
{% endtab %}

{% tab title="g\_face" %}

<figure><img src="https://demo.imagemash.io/g_face,w_300,h_300/woman.jpg" alt=""><figcaption><p>g_face,w_300,h_300</p></figcaption></figure>

`https://demo.imagemash.io/g_face,w_300,h_300/woman.jpg`

g\_face tries to focus on the face as much as possible while trying to show you most of the image.
{% endtab %}

{% tab title="c\_thumb+g\_face" %}
Example usage of [c\_thumb](/image-transform/transform-options/crop.md#thumb-c_thumb) + g\_face.

`https://demo.imagemash.io/c_thumb,g_face,w_300,h_300/woman.jpg`

<figure><img src="https://demo.imagemash.io/c_thumb,g_face,w_300,h_300/woman.jpg" alt=""><figcaption><p>c_thumb,g_face,w_300,h_300</p></figcaption></figure>

Example of creating a nice portrait from an image.

`https://demo.imagemash.io/c_thumb,g_face,w_300,h_450/woman.jpg`

<figure><img src="https://demo.imagemash.io/c_thumb,g_face,w_300,h_450/woman.jpg" alt=""><figcaption><p>c_thumb,g_face,w_300,h_450</p></figcaption></figure>
{% endtab %}

{% tab title="Face(s)" %}

<figure><img src="https://demo.imagemash.io/w_400/couple.jpg" alt=""><figcaption><p><a href="https://demo.imagemash.io/couple.jpg">https://demo.imagemash.io/couple.jpg</a> (Original)</p></figcaption></figure>

You can also use [c\_crop](/image-transform/transform-options/crop.md#crop-c_crop). Since c\_crop needs a region to crop, g\_face provides that region. If you are going to make thumbnails, we suggest you use [c\_thumb](/image-transform/transform-options/crop.md#thumb-c_thumb) instead of c\_crop. As it is specifically designed for that purpose.

`https://demo.imagemash.io/c_crop,g_face,w_200,h_200/couple.jpg`

<figure><img src="https://demo.imagemash.io/c_crop,g_face,w_200,h_200/couple.jpg" alt=""><figcaption><p>c_crop,g_face,w_200,h_200</p></figcaption></figure>

Use g\_faces to focus on multiple faces.

`https://demo.imagemash.io/c_crop,g_faces,w_200,h_200/couple.jpg`

<figure><img src="https://demo.imagemash.io/c_crop,g_faces,w_200,h_200/couple.jpg" alt=""><figcaption><p>c_crop,g_faces,w_200,h_200</p></figcaption></figure>

Enlarge the view by setting its width and height to larger values. faces will be the center point of your image as much as possible.

`https://demo.imagemash.io/c_crop,g_faces,w_500,h_500/couple.jpg`

<figure><img src="https://demo.imagemash.io/c_crop,g_faces,w_500,h_500/couple.jpg" alt=""><figcaption><p>c_crop,g_faces,w_500,h_500</p></figcaption></figure>
{% endtab %}

{% tab title="Object(s)" %}
As with all other Gravity values, g\_\<objectname> also creates a region to focus on.

Provide a simple object name.

Use the plural of an object if you want to focus on multiples of objects. Eg. chairs, sheeps, ...

If you don't provide height and width while using c\_crop or c\_thumb, the returned image will be the exact size of the detected object.

<figure><img src="https://demo.imagemash.io/w_300/kitchen.jpg" alt=""><figcaption><p><a href="https://demo.imagemash.io/kitchen.jpg">https://demo.imagemash.io/kitchen.jpg</a></p></figcaption></figure>

`https://demo.imagemash.io/c_crop,g_microwave/kitchen.jpg`

<figure><img src="https://demo.imagemash.io/c_crop,g_microwave/kitchen.jpg" alt=""><figcaption><p>c,crop,g_microwave</p></figcaption></figure>

`https://demo.imagemash.io/c_crop,g_chair/kitchen.jpg`

<figure><img src="https://demo.imagemash.io/c_crop,g_chair/kitchen.jpg" alt=""><figcaption><p>c_crop,g_chair</p></figcaption></figure>

`https://demo.imagemash.io/c_crop,g_chairs/kitchen.jpg`

<figure><img src="https://demo.imagemash.io/c_crop,g_chairs/kitchen.jpg" alt=""><figcaption><p>c_crop,g_chairs</p></figcaption></figure>

`https://demo.imagemash.io/c_crop,g_pot/kitchen.jpg`

<figure><img src="https://demo.imagemash.io/c_crop,g_pot/kitchen.jpg" alt=""><figcaption><p>c_crop,g_pot</p></figcaption></figure>
{% endtab %}
{% endtabs %}
