> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# Object-aware cropping


When object-aware cropping is invoked, Cloudinary applies advanced AI-based object detection algorithms on the fly during the crop process. You can either use it in conjunction with auto-gravity to give higher priority to the objects you care about, or directly specify that the crop should be exactly based on the detected coordinates of the specified objects.

Watch this demo to see how the same image is cropped according to the parameters specified in the URL:

## Applying object-aware cropping

After registering for the Cloudinary AI Content Analysis add-on, you can apply it in one of two ways:

* **Automatic gravity with a high weighting towards a specified object**
This variant of [auto-gravity cropping](resizing_and_cropping#automatic_cropping_g_auto) enables you to indicate specific objects or object categories that should be given priority when parts of a photo are cropped out.  This is done by specifying an object or an object category as the `focal_gravity` attribute for the `auto` gravity parameter (for example, `g_auto:cat` in URLs) together with a cropping option. If the specified content is not found in the image, the gravity is determined by the standard auto-gravity algorithm.

* **Object-specific gravity**
By specifying an object or object category as the gravity parameter (for example, `g_cat` in URLs) together with a cropping option, you can accurately crop around objects without needing to specify dimensions or aspect ratio. If the specified content is not found in the image, the gravity remains at the center of the image.

When specifying an object or category, you can optionally include a specific model (that [supports bounding boxes](cloudinary_ai_content_analysis_addon#model_capabilities)) and version. For example, you can specify:

* Only the object/category, e.g.: `g_auto:cat` or `g_cat`
* The model with the object/category, e.g.: `g_auto:coco_cat` or `g_coco_cat`
* The model and version with object/category, e.g.: `g_auto:coco_v2_cat` or `g_coco_v2_cat`

If you choose not to specify a model, each model that [supports bounding boxes](cloudinary_ai_content_analysis_addon#model_capabilities) is invoked in turn until the specified content is detected.  The order in which they are invoked is: **coco > cld-fashion > lvis > unidet > human-anatomy > cld-text**. 

> **NOTE**: If you have any private models set up, these are invoked first, in the order that was predefined for your product environment.

Consider the original image of a kitchen below:

 

Using auto-gravity, you can deliver a square thumbnail crop that prioritizes the detected coordinates of the sink, microwave, or refrigerator. To do this, specify the relevant object option for the `g_auto` gravity definition in conjunction with the `thumb` or `auto` cropping option:

![Crop a kitchen photo to a square thumbnail, using the detected sink as the thumb coordinates](https://res.cloudinary.com/demo/image/upload/ar_1.0,c_auto,g_auto:sink,w_600/docs/kitchen1.jpg "with_image:false")

```nodejs
cloudinary.image("docs/kitchen1.jpg", {aspect_ratio: "1.0", gravity: "auto:sink", width: 600, crop: "auto"})
```

```react
import { auto } from "@cloudinary/url-gen/actions/resize";
import { autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  auto()
    .width(600)
    .aspectRatio("1.0")
    .gravity(autoGravity().autoFocus(focusOn(sink())))
);
```

```vue
import { auto } from "@cloudinary/url-gen/actions/resize";
import { autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  auto()
    .width(600)
    .aspectRatio("1.0")
    .gravity(autoGravity().autoFocus(focusOn(sink())))
);
```

```angular
import { auto } from "@cloudinary/url-gen/actions/resize";
import { autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  auto()
    .width(600)
    .aspectRatio("1.0")
    .gravity(autoGravity().autoFocus(focusOn(sink())))
);
```

```js
import { auto } from "@cloudinary/url-gen/actions/resize";
import { autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  auto()
    .width(600)
    .aspectRatio("1.0")
    .gravity(autoGravity().autoFocus(focusOn(sink())))
);
```

```python
CloudinaryImage("docs/kitchen1.jpg").image(aspect_ratio="1.0", gravity="auto:sink", width=600, crop="auto")
```

```php
use Cloudinary\Transformation\Resize;
use Cloudinary\Transformation\Gravity;
use Cloudinary\Transformation\AutoFocus;
use Cloudinary\Transformation\FocusOn;

(new ImageTag('docs/kitchen1.jpg'))
	->resize(Resize::auto()->width(600)
->aspectRatio(1.0)
	->gravity(
	Gravity::autoGravity()
	->autoFocus(
	AutoFocus::focusOn(
	FocusOn::sink()))
	)
	);
```

```java
cloudinary.url().transformation(new Transformation().aspectRatio("1.0").gravity("auto:sink").width(600).crop("auto")).imageTag("docs/kitchen1.jpg");
```

```ruby
cl_image_tag("docs/kitchen1.jpg", aspect_ratio: "1.0", gravity: "auto:sink", width: 600, crop: "auto")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().AspectRatio("1.0").Gravity("auto:sink").Width(600).Crop("auto")).BuildImageTag("docs/kitchen1.jpg")
```

```dart
cloudinary.image('docs/kitchen1.jpg').transformation(Transformation()
	.resize(Resize.auto().width(600)
.aspectRatio('1.0')
	.gravity(
	Gravity.autoGravity()
	.autoFocus(
	AutoFocus.focusOn(
	FocusOn.sink()))
	)
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setAspectRatio("1.0").setGravity("auto:sink").setWidth(600).setCrop("auto")).generate("docs/kitchen1.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().aspectRatio("1.0").gravity("auto:sink").width(600).crop("auto")).generate("docs/kitchen1.jpg");
```

```flutter
cloudinary.image('docs/kitchen1.jpg').transformation(Transformation()
	.resize(Resize.auto().width(600)
.aspectRatio('1.0')
	.gravity(
	Gravity.autoGravity()
	.autoFocus(
	AutoFocus.focusOn(
	FocusOn.sink()))
	)
	));
```

```kotlin
cloudinary.image {
	publicId("docs/kitchen1.jpg")
	 resize(Resize.auto() { width(600)
 aspectRatio(1.0F)
	 gravity(
	Gravity.autoGravity() {
	 autoFocus(
	AutoFocus.focusOn(
	FocusOn.sink()))
	 })
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("docs/kitchen1.jpg", {aspect_ratio: "1.0", gravity: "auto:sink", width: 600, crop: "auto"})
```

```react_native
import { auto } from "@cloudinary/url-gen/actions/resize";
import { autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  auto()
    .width(600)
    .aspectRatio("1.0")
    .gravity(autoGravity().autoFocus(focusOn(sink())))
);
```

g_auto:sink

g_auto:microwave

g_auto:refrigerator

 

Using object-specific gravity, you can choose not to give dimensions or aspect ratio, and deliver an image that is tightly cropped to the object.  To do this, specify the relevant object option for the gravity definition in conjunction with the `crop` cropping option:

![Crop a kitchen photo to the detected sink](https://res.cloudinary.com/demo/image/upload/c_crop,g_sink/docs/kitchen1.jpg "with_image:false")

```nodejs
cloudinary.image("docs/kitchen1.jpg", {gravity: "sink", crop: "crop"})
```

```react
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  crop().gravity(focusOn(sink()))
);
```

```vue
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  crop().gravity(focusOn(sink()))
);
```

```angular
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  crop().gravity(focusOn(sink()))
);
```

```js
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  crop().gravity(focusOn(sink()))
);
```

```python
CloudinaryImage("docs/kitchen1.jpg").image(gravity="sink", crop="crop")
```

```php
use Cloudinary\Transformation\Resize;
use Cloudinary\Transformation\Gravity;
use Cloudinary\Transformation\FocusOn;

(new ImageTag('docs/kitchen1.jpg'))
	->resize(Resize::crop()
	->gravity(
	Gravity::focusOn(
	FocusOn::sink()))
	);
```

```java
cloudinary.url().transformation(new Transformation().gravity("sink").crop("crop")).imageTag("docs/kitchen1.jpg");
```

```ruby
cl_image_tag("docs/kitchen1.jpg", gravity: "sink", crop: "crop")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("sink").Crop("crop")).BuildImageTag("docs/kitchen1.jpg")
```

```dart
cloudinary.image('docs/kitchen1.jpg').transformation(Transformation()
	.resize(Resize.crop()
	.gravity(
	Gravity.focusOn(
	FocusOn.sink()))
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setGravity("sink").setCrop("crop")).generate("docs/kitchen1.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().gravity("sink").crop("crop")).generate("docs/kitchen1.jpg");
```

```flutter
cloudinary.image('docs/kitchen1.jpg').transformation(Transformation()
	.resize(Resize.crop()
	.gravity(
	Gravity.focusOn(
	FocusOn.sink()))
	));
```

```kotlin
cloudinary.image {
	publicId("docs/kitchen1.jpg")
	 resize(Resize.crop() {
	 gravity(
	Gravity.focusOn(
	FocusOn.sink()))
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("docs/kitchen1.jpg", {gravity: "sink", crop: "crop"})
```

```react_native
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  crop().gravity(focusOn(sink()))
);
```

g_sink

g_microwave

g_refrigerator

 

You can also specify an aspect ratio together with the `crop` cropping option, without including specific dimensions. This keeps the object but may show more of the image to fit the aspect ratio.

![Crop a kitchen photo to the detected sink with an aspect ratio of 1](https://res.cloudinary.com/demo/image/upload/c_crop,g_sink,ar_1/docs/kitchen1.jpg "with_image:false")

```nodejs
cloudinary.image("docs/kitchen1.jpg", {gravity: "sink", aspect_ratio: "1", crop: "crop"})
```

```react
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  crop()
    .aspectRatio("1.0")
    .gravity(focusOn(sink()))
);
```

```vue
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  crop()
    .aspectRatio("1.0")
    .gravity(focusOn(sink()))
);
```

```angular
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  crop()
    .aspectRatio("1.0")
    .gravity(focusOn(sink()))
);
```

```js
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  crop()
    .aspectRatio("1.0")
    .gravity(focusOn(sink()))
);
```

```python
CloudinaryImage("docs/kitchen1.jpg").image(gravity="sink", aspect_ratio="1", crop="crop")
```

```php
use Cloudinary\Transformation\Resize;
use Cloudinary\Transformation\Gravity;
use Cloudinary\Transformation\FocusOn;

(new ImageTag('docs/kitchen1.jpg'))
	->resize(Resize::crop()->aspectRatio(1.0)
	->gravity(
	Gravity::focusOn(
	FocusOn::sink()))
	);
```

```java
cloudinary.url().transformation(new Transformation().gravity("sink").aspectRatio("1").crop("crop")).imageTag("docs/kitchen1.jpg");
```

```ruby
cl_image_tag("docs/kitchen1.jpg", gravity: "sink", aspect_ratio: "1", crop: "crop")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("sink").AspectRatio("1").Crop("crop")).BuildImageTag("docs/kitchen1.jpg")
```

```dart
cloudinary.image('docs/kitchen1.jpg').transformation(Transformation()
	.resize(Resize.crop().aspectRatio('1.0')
	.gravity(
	Gravity.focusOn(
	FocusOn.sink()))
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setGravity("sink").setAspectRatio("1").setCrop("crop")).generate("docs/kitchen1.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().gravity("sink").aspectRatio("1").crop("crop")).generate("docs/kitchen1.jpg");
```

```flutter
cloudinary.image('docs/kitchen1.jpg').transformation(Transformation()
	.resize(Resize.crop().aspectRatio('1.0')
	.gravity(
	Gravity.focusOn(
	FocusOn.sink()))
	));
```

```kotlin
cloudinary.image {
	publicId("docs/kitchen1.jpg")
	 resize(Resize.crop() { aspectRatio(1.0F)
	 gravity(
	Gravity.focusOn(
	FocusOn.sink()))
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("docs/kitchen1.jpg", {gravity: "sink", aspect_ratio: "1", crop: "crop"})
```

```react_native
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { sink } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/kitchen1.jpg").resize(
  crop()
    .aspectRatio("1.0")
    .gravity(focusOn(sink()))
);
```

g_sink

g_microwave

g_refrigerator

 

In addition to the [crop](resizing_and_cropping#crop), [thumb](resizing_and_cropping#thumb) and [auto](resizing_and_cropping#c_auto) cropping modes, object aware cropping can also be used with the [fill](resizing_and_cropping#fill) and [lfill](resizing_and_cropping#lfill_limit_fill) (limit fill) cropping modes. The [fill_pad](resizing_and_cropping#fill_pad) and [auto_pad](resizing_and_cropping#auto_pad) cropping modes work with the auto-gravity variant of object aware cropping, but not object-specific gravity.

## Notes on specifying categories and objects

When applying object-aware cropping, you can specify either individual objects or more general object categories.

* When you specify a category, the algorithm gives priority to any objects that are detected from that category.
* The regular auto-gravity behavior also impacts the cropping decision. But if requested objects are detected, they get significantly higher priority than the subjects or salient areas that the regular auto-gravity algorithm selects.
* If you specify the generic `object` category with auto-gravity (`g_auto:object`), then any detected objects from any category get priority.
* If there are multiple objects of the same type in the image, object-specific gravity selects the most prominent of the objects, and bases its crop around only that object, whereas auto-gravity may choose to keep more than one of the objects in the crop.
* The categories and objects also work in their plural forms when using object-specific gravity.  So, for example, `c_crop,g_birds` keeps all birds in the crop, whereas `c_crop,g_bird` keeps only the most prominent bird. 

## Combining focal gravity options using auto-gravity

When using `auto` gravity to determine the area to keep in a crop, you can specify multiple `focal_gravity` options.

This means that in a single auto-gravity parameter, you can optionally specify:

* One or multiple objects (from the same or different categories and/or models)
* Built-in focal gravity options such as `face`/`faces` or `custom_no_override`
* Other add-on based focal gravity options, such as the `adv_face`, `adv_eyes` options from the [Advanced Facial Attributes Detection add-on](advanced_facial_attributes_detection_addon)
* Only the `classic` or only the `subject` [auto-gravity algorithm](resizing_and_cropping#selecting_a_single_automatic_gravity_algorithm), which in some cases may have some impact on the exact coordinates of the crop, even if other specified objects or focal gravity options are detected.  Note that the default algorithm, which combines both of these algorithms, is recommended in the majority of cases.

For example, your auto-gravity URL parameter might be: `g_auto:cat:sofa:faces:adv_eyes`

This would instruct the cropping mechanism to give top priority to any cats, sofas, faces, or eyes detected in the photo.

For a complete list of all `focal_gravity` options, see the [g_\<special_position\>](transformation_reference#g_special_position) section of the _Transformation URL API Reference_.

> **INFO**:
>
> * The focal gravity options can be specified in any order. The order does not impact the result. 

> * When multiple items are detected that match the requested focal options, larger, more central, and more in-focus (less blurry) objects will get higher priority. In special cases, it's possible to fine-tune this default prioritization further. For details, contact [support](https://support.cloudinary.com/hc/en-us/requests/new).

> * If a particular image has **custom** coordinates defined, those coordinates always override all other focal gravity options, unless you use the `custom_no_override` option in conjunction with the other options, in which case the custom coordinates are taken into account when determining the gravity (see [Custom coordinates with auto gravity](custom_focus_areas#custom_coordinates_with_auto_gravity)).

## Combining focal gravity options using object-specific gravity

When using object-specific gravity to determine the area to keep in a crop, you can specify multiple `focal_gravity` options, but unlike auto-gravity, the order in which they are specified has an impact on the delivered image.

For example, consider this photo of a cat and dog:

 

By setting the `gravity` parameter to `cat:dog` the cat gets precedence:

![Cat gets precedence over dog](https://res.cloudinary.com/demo/image/upload/c_crop,g_cat:dog/docs/one_cat_one_dog.jpg "with_image:false")

```nodejs
cloudinary.image("docs/one_cat_one_dog.jpg", {gravity: "cat:dog", crop: "crop"})
```

```react
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { cat, dog } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/one_cat_one_dog.jpg").resize(
  crop().gravity(focusOn(cat(), dog()))
);
```

```vue
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { cat, dog } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/one_cat_one_dog.jpg").resize(
  crop().gravity(focusOn(cat(), dog()))
);
```

```angular
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { cat, dog } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/one_cat_one_dog.jpg").resize(
  crop().gravity(focusOn(cat(), dog()))
);
```

```js
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { cat, dog } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/one_cat_one_dog.jpg").resize(
  crop().gravity(focusOn(cat(), dog()))
);
```

```python
CloudinaryImage("docs/one_cat_one_dog.jpg").image(gravity="cat:dog", crop="crop")
```

```php
use Cloudinary\Transformation\Resize;
use Cloudinary\Transformation\Gravity;
use Cloudinary\Transformation\FocusOn;

(new ImageTag('docs/one_cat_one_dog.jpg'))
	->resize(Resize::crop()
	->gravity(
	Gravity::focusOn(
	FocusOn::cat(),
	FocusOn::dog()))
	);
```

```java
cloudinary.url().transformation(new Transformation().gravity("cat:dog").crop("crop")).imageTag("docs/one_cat_one_dog.jpg");
```

```ruby
cl_image_tag("docs/one_cat_one_dog.jpg", gravity: "cat:dog", crop: "crop")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("cat:dog").Crop("crop")).BuildImageTag("docs/one_cat_one_dog.jpg")
```

```dart
cloudinary.image('docs/one_cat_one_dog.jpg').transformation(Transformation()
	.resize(Resize.crop()
	.gravity(
	Gravity.focusOn(
	FocusOn.cat(),
	FocusOn.dog()))
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setGravity("cat:dog").setCrop("crop")).generate("docs/one_cat_one_dog.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().gravity("cat:dog").crop("crop")).generate("docs/one_cat_one_dog.jpg");
```

```flutter
cloudinary.image('docs/one_cat_one_dog.jpg').transformation(Transformation()
	.resize(Resize.crop()
	.gravity(
	Gravity.focusOn(
	FocusOn.cat(),
	FocusOn.dog()))
	));
```

```kotlin
cloudinary.image {
	publicId("docs/one_cat_one_dog.jpg")
	 resize(Resize.crop() {
	 gravity(
	Gravity.focusOn(
	FocusOn.cat(),
	FocusOn.dog()))
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("docs/one_cat_one_dog.jpg", {gravity: "cat:dog", crop: "crop"})
```

```react_native
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { cat, dog } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/one_cat_one_dog.jpg").resize(
  crop().gravity(focusOn(cat(), dog()))
);
```

Whereas, if you switch the order to `dog:cat` the dog gets precedence:

![Dog gets precedence over cat](https://res.cloudinary.com/demo/image/upload/c_crop,g_dog:cat/docs/one_cat_one_dog.jpg "with_image:false")

```nodejs
cloudinary.image("docs/one_cat_one_dog.jpg", {gravity: "dog:cat", crop: "crop"})
```

```react
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, cat } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/one_cat_one_dog.jpg").resize(
  crop().gravity(focusOn(dog(), cat()))
);
```

```vue
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, cat } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/one_cat_one_dog.jpg").resize(
  crop().gravity(focusOn(dog(), cat()))
);
```

```angular
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, cat } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/one_cat_one_dog.jpg").resize(
  crop().gravity(focusOn(dog(), cat()))
);
```

```js
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, cat } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/one_cat_one_dog.jpg").resize(
  crop().gravity(focusOn(dog(), cat()))
);
```

```python
CloudinaryImage("docs/one_cat_one_dog.jpg").image(gravity="dog:cat", crop="crop")
```

```php
use Cloudinary\Transformation\Resize;
use Cloudinary\Transformation\Gravity;
use Cloudinary\Transformation\FocusOn;

(new ImageTag('docs/one_cat_one_dog.jpg'))
	->resize(Resize::crop()
	->gravity(
	Gravity::focusOn(
	FocusOn::dog(),
	FocusOn::cat()))
	);
```

```java
cloudinary.url().transformation(new Transformation().gravity("dog:cat").crop("crop")).imageTag("docs/one_cat_one_dog.jpg");
```

```ruby
cl_image_tag("docs/one_cat_one_dog.jpg", gravity: "dog:cat", crop: "crop")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("dog:cat").Crop("crop")).BuildImageTag("docs/one_cat_one_dog.jpg")
```

```dart
cloudinary.image('docs/one_cat_one_dog.jpg').transformation(Transformation()
	.resize(Resize.crop()
	.gravity(
	Gravity.focusOn(
	FocusOn.dog(),
	FocusOn.cat()))
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setGravity("dog:cat").setCrop("crop")).generate("docs/one_cat_one_dog.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().gravity("dog:cat").crop("crop")).generate("docs/one_cat_one_dog.jpg");
```

```flutter
cloudinary.image('docs/one_cat_one_dog.jpg').transformation(Transformation()
	.resize(Resize.crop()
	.gravity(
	Gravity.focusOn(
	FocusOn.dog(),
	FocusOn.cat()))
	));
```

```kotlin
cloudinary.image {
	publicId("docs/one_cat_one_dog.jpg")
	 resize(Resize.crop() {
	 gravity(
	Gravity.focusOn(
	FocusOn.dog(),
	FocusOn.cat()))
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("docs/one_cat_one_dog.jpg", {gravity: "dog:cat", crop: "crop"})
```

```react_native
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, cat } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/one_cat_one_dog.jpg").resize(
  crop().gravity(focusOn(dog(), cat()))
);
```

You can also combine the `auto` option to invoke the auto-gravity algorithm if none of the specified objects are found.  For example:

* `g_dog:cat:auto` - auto-gravity is invoked only if no dogs and cats are detected. 
* `g_dog:auto:cat` - auto-gravity weighted by cat (`g_auto:cat`) is invoked if no dogs are detected.

> **INFO**: If you use the `auto` option then you also need to specify at least one dimension parameter (width or height).

For example, consider this photo of a cat and three birds:

 

As there is no dog in the photo, auto-gravity weighted by bird is invoked when using `dog:auto:bird`.  In this case, two birds are kept in the crop:

![Original](https://res.cloudinary.com/demo/image/upload/c_crop,g_dog:auto:bird,w_600,h_800/docs/cat_and_birds.jpg "with_image:false")

```nodejs
cloudinary.image("docs/cat_and_birds.jpg", {gravity: "dog:auto:bird", width: 600, height: 800, crop: "crop"})
```

```react
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn, autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, bird } from "@cloudinary/url-gen/qualifiers/focusOn";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";

new CloudinaryImage("docs/cat_and_birds.jpg").resize(
  crop()
    .width(600)
    .height(800)
    .gravity(
      focusOn(dog()).fallbackGravity(autoGravity().autoFocus(focusOn(bird())))
    )
);
```

```vue
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn, autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, bird } from "@cloudinary/url-gen/qualifiers/focusOn";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";

new CloudinaryImage("docs/cat_and_birds.jpg").resize(
  crop()
    .width(600)
    .height(800)
    .gravity(
      focusOn(dog()).fallbackGravity(autoGravity().autoFocus(focusOn(bird())))
    )
);
```

```angular
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn, autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, bird } from "@cloudinary/url-gen/qualifiers/focusOn";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";

new CloudinaryImage("docs/cat_and_birds.jpg").resize(
  crop()
    .width(600)
    .height(800)
    .gravity(
      focusOn(dog()).fallbackGravity(autoGravity().autoFocus(focusOn(bird())))
    )
);
```

```js
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn, autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, bird } from "@cloudinary/url-gen/qualifiers/focusOn";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";

new CloudinaryImage("docs/cat_and_birds.jpg").resize(
  crop()
    .width(600)
    .height(800)
    .gravity(
      focusOn(dog()).fallbackGravity(autoGravity().autoFocus(focusOn(bird())))
    )
);
```

```python
CloudinaryImage("docs/cat_and_birds.jpg").image(gravity="dog:auto:bird", width=600, height=800, crop="crop")
```

```php
use Cloudinary\Transformation\Resize;
use Cloudinary\Transformation\Gravity;
use Cloudinary\Transformation\FocusOn;
use Cloudinary\Transformation\AutoFocus;

(new ImageTag('docs/cat_and_birds.jpg'))
	->resize(Resize::crop()->width(600)
->height(800)
	->gravity(
	Gravity::focusOn(
	FocusOn::dog())
	->fallbackGravity(
	Gravity::autoGravity()
	->autoFocus(
	AutoFocus::focusOn(
	FocusOn::bird()))
	)
	)
	);
```

```java
cloudinary.url().transformation(new Transformation().gravity("dog:auto:bird").width(600).height(800).crop("crop")).imageTag("docs/cat_and_birds.jpg");
```

```ruby
cl_image_tag("docs/cat_and_birds.jpg", gravity: "dog:auto:bird", width: 600, height: 800, crop: "crop")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("dog:auto:bird").Width(600).Height(800).Crop("crop")).BuildImageTag("docs/cat_and_birds.jpg")
```

```dart
cloudinary.image('docs/cat_and_birds.jpg').transformation(Transformation()
	.resize(Resize.crop().width(600)
.height(800)
	.gravity(
	Gravity.focusOn(
	FocusOn.dog())
	.fallbackGravity(
	Gravity.autoGravity()
	.autoFocus(
	AutoFocus.focusOn(
	FocusOn.bird()))
	)
	)
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setGravity("dog:auto:bird").setWidth(600).setHeight(800).setCrop("crop")).generate("docs/cat_and_birds.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().gravity("dog:auto:bird").width(600).height(800).crop("crop")).generate("docs/cat_and_birds.jpg");
```

```flutter
cloudinary.image('docs/cat_and_birds.jpg').transformation(Transformation()
	.resize(Resize.crop().width(600)
.height(800)
	.gravity(
	Gravity.focusOn(
	FocusOn.dog())
	.fallbackGravity(
	Gravity.autoGravity()
	.autoFocus(
	AutoFocus.focusOn(
	FocusOn.bird()))
	)
	)
	));
```

```kotlin
cloudinary.image {
	publicId("docs/cat_and_birds.jpg")
	 resize(Resize.crop() { width(600)
 height(800)
	 gravity(
	Gravity.focusOn(
	FocusOn.dog()) {
	 fallbackGravity(
	Gravity.autoGravity() {
	 autoFocus(
	AutoFocus.focusOn(
	FocusOn.bird()))
	 })
	 })
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("docs/cat_and_birds.jpg", {gravity: "dog:auto:bird", width: 600, height: 800, crop: "crop"})
```

```react_native
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn, autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, bird } from "@cloudinary/url-gen/qualifiers/focusOn";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";

new CloudinaryImage("docs/cat_and_birds.jpg").resize(
  crop()
    .width(600)
    .height(800)
    .gravity(
      focusOn(dog()).fallbackGravity(autoGravity().autoFocus(focusOn(bird())))
    )
);
```

Notice that if auto-gravity is not specified, the object-specific algorithm chooses the most prominent bird out of the three and only keeps this bird in the crop:

![Original](https://res.cloudinary.com/demo/image/upload/c_crop,g_dog:bird,w_600,h_800/docs/cat_and_birds.jpg "with_image:false")

```nodejs
cloudinary.image("docs/cat_and_birds.jpg", {gravity: "dog:bird", width: 600, height: 800, crop: "crop"})
```

```react
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, bird } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/cat_and_birds.jpg").resize(
  crop()
    .width(600)
    .height(800)
    .gravity(focusOn(dog(), bird()))
);
```

```vue
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, bird } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/cat_and_birds.jpg").resize(
  crop()
    .width(600)
    .height(800)
    .gravity(focusOn(dog(), bird()))
);
```

```angular
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, bird } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/cat_and_birds.jpg").resize(
  crop()
    .width(600)
    .height(800)
    .gravity(focusOn(dog(), bird()))
);
```

```js
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, bird } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/cat_and_birds.jpg").resize(
  crop()
    .width(600)
    .height(800)
    .gravity(focusOn(dog(), bird()))
);
```

```python
CloudinaryImage("docs/cat_and_birds.jpg").image(gravity="dog:bird", width=600, height=800, crop="crop")
```

```php
use Cloudinary\Transformation\Resize;
use Cloudinary\Transformation\Gravity;
use Cloudinary\Transformation\FocusOn;

(new ImageTag('docs/cat_and_birds.jpg'))
	->resize(Resize::crop()->width(600)
->height(800)
	->gravity(
	Gravity::focusOn(
	FocusOn::dog(),
	FocusOn::bird()))
	);
```

```java
cloudinary.url().transformation(new Transformation().gravity("dog:bird").width(600).height(800).crop("crop")).imageTag("docs/cat_and_birds.jpg");
```

```ruby
cl_image_tag("docs/cat_and_birds.jpg", gravity: "dog:bird", width: 600, height: 800, crop: "crop")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("dog:bird").Width(600).Height(800).Crop("crop")).BuildImageTag("docs/cat_and_birds.jpg")
```

```dart
cloudinary.image('docs/cat_and_birds.jpg').transformation(Transformation()
	.resize(Resize.crop().width(600)
.height(800)
	.gravity(
	Gravity.focusOn(
	FocusOn.dog(),
	FocusOn.bird()))
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setGravity("dog:bird").setWidth(600).setHeight(800).setCrop("crop")).generate("docs/cat_and_birds.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().gravity("dog:bird").width(600).height(800).crop("crop")).generate("docs/cat_and_birds.jpg");
```

```flutter
cloudinary.image('docs/cat_and_birds.jpg').transformation(Transformation()
	.resize(Resize.crop().width(600)
.height(800)
	.gravity(
	Gravity.focusOn(
	FocusOn.dog(),
	FocusOn.bird()))
	));
```

```kotlin
cloudinary.image {
	publicId("docs/cat_and_birds.jpg")
	 resize(Resize.crop() { width(600)
 height(800)
	 gravity(
	Gravity.focusOn(
	FocusOn.dog(),
	FocusOn.bird()))
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("docs/cat_and_birds.jpg", {gravity: "dog:bird", width: 600, height: 800, crop: "crop"})
```

```react_native
import { crop } from "@cloudinary/url-gen/actions/resize";
import { focusOn } from "@cloudinary/url-gen/qualifiers/gravity";
import { dog, bird } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/cat_and_birds.jpg").resize(
  crop()
    .width(600)
    .height(800)
    .gravity(focusOn(dog(), bird()))
);
```

## Specifying objects to avoid using auto-gravity

In addition to specifying objects to keep in an image, you can specify objects that you would rather not see.  To minimize the likelihood of including a particular object in the cropped image, use auto-gravity with the `avoid` option for the relevant object or category.

For example, in photos like the one below, you may prefer not to include people because the purpose of the photo is to show an interesting storefront, and the people are a distraction.

 

Using `g_auto` by itself makes the people the focal point, but if we use `g_auto:person_avoid`, the other side of the photo is shown, without the people.

![Crop a picture avoiding people](https://res.cloudinary.com/demo/image/upload/w_500,ar_1.0,c_fill,g_auto:person_avoid/docs/store_front.jpg "with_image:false")

```nodejs
cloudinary.image("docs/store_front.jpg", {width: 500, aspect_ratio: "1.0", gravity: "auto:person_avoid", crop: "fill"})
```

```react
import { fill } from "@cloudinary/url-gen/actions/resize";
import { autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";
import { person } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/store_front.jpg").resize(
  fill()
    .width(500)
    .aspectRatio("1.0")
    .gravity(autoGravity().autoFocus(focusOn(person()).avoid()))
);
```

```vue
import { fill } from "@cloudinary/url-gen/actions/resize";
import { autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";
import { person } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/store_front.jpg").resize(
  fill()
    .width(500)
    .aspectRatio("1.0")
    .gravity(autoGravity().autoFocus(focusOn(person()).avoid()))
);
```

```angular
import { fill } from "@cloudinary/url-gen/actions/resize";
import { autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";
import { person } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/store_front.jpg").resize(
  fill()
    .width(500)
    .aspectRatio("1.0")
    .gravity(autoGravity().autoFocus(focusOn(person()).avoid()))
);
```

```js
import { fill } from "@cloudinary/url-gen/actions/resize";
import { autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";
import { person } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/store_front.jpg").resize(
  fill()
    .width(500)
    .aspectRatio("1.0")
    .gravity(autoGravity().autoFocus(focusOn(person()).avoid()))
);
```

```python
CloudinaryImage("docs/store_front.jpg").image(width=500, aspect_ratio="1.0", gravity="auto:person_avoid", crop="fill")
```

```php
use Cloudinary\Transformation\Resize;
use Cloudinary\Transformation\Gravity;
use Cloudinary\Transformation\AutoFocus;
use Cloudinary\Transformation\FocusOn;

(new ImageTag('docs/store_front.jpg'))
	->resize(Resize::fill()->width(500)
->aspectRatio(1.0)
	->gravity(
	Gravity::autoGravity()
	->autoFocus(
	AutoFocus::focusOn(
	FocusOn::person())->avoid())
	)
	);
```

```java
cloudinary.url().transformation(new Transformation().width(500).aspectRatio("1.0").gravity("auto:person_avoid").crop("fill")).imageTag("docs/store_front.jpg");
```

```ruby
cl_image_tag("docs/store_front.jpg", width: 500, aspect_ratio: "1.0", gravity: "auto:person_avoid", crop: "fill")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(500).AspectRatio("1.0").Gravity("auto:person_avoid").Crop("fill")).BuildImageTag("docs/store_front.jpg")
```

```dart
cloudinary.image('docs/store_front.jpg').transformation(Transformation()
	.resize(Resize.fill().width(500)
.aspectRatio('1.0')
	.gravity(
	Gravity.autoGravity()
	.autoFocus(
	AutoFocus.focusOn(
	FocusOn.person()).avoid())
	)
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setWidth(500).setAspectRatio("1.0").setGravity("auto:person_avoid").setCrop("fill")).generate("docs/store_front.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().width(500).aspectRatio("1.0").gravity("auto:person_avoid").crop("fill")).generate("docs/store_front.jpg");
```

```flutter
cloudinary.image('docs/store_front.jpg').transformation(Transformation()
	.resize(Resize.fill().width(500)
.aspectRatio('1.0')
	.gravity(
	Gravity.autoGravity()
	.autoFocus(
	AutoFocus.focusOn(
	FocusOn.person()).avoid())
	)
	));
```

```kotlin
cloudinary.image {
	publicId("docs/store_front.jpg")
	 resize(Resize.fill() { width(500)
 aspectRatio(1.0F)
	 gravity(
	Gravity.autoGravity() {
	 autoFocus(
	AutoFocus.focusOn(
	FocusOn.person()) { avoid() })
	 })
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("docs/store_front.jpg", {width: 500, aspect_ratio: "1.0", gravity: "auto:person_avoid", crop: "fill"})
```

```react_native
import { fill } from "@cloudinary/url-gen/actions/resize";
import { autoGravity } from "@cloudinary/url-gen/qualifiers/gravity";
import { focusOn } from "@cloudinary/url-gen/qualifiers/autoFocus";
import { person } from "@cloudinary/url-gen/qualifiers/focusOn";

new CloudinaryImage("docs/store_front.jpg").resize(
  fill()
    .width(500)
    .aspectRatio("1.0")
    .gravity(autoGravity().autoFocus(focusOn(person()).avoid()))
);
```

g_auto

g_auto:person_avoid

 

## Choosing the cropping mode

When you specify an object, either specifically or in your auto-gravity parameter, the Object-Aware Cropping AI algorithm detects the coordinates of the object and those coordinates are used by the cropping mode. 

* When using **thumb** cropping (`c_thumb`), the image is cropped as closely as possible to the detected coordinates of the object given the requested aspect ratio, and then scaled to the requested pixel size. Note that if the requested pixel size is greater than the crop, the image is not scaled up, but filled with further pixels from the image.

* When using **crop** mode (`c_crop`), the detected coordinates are prioritized as the area to keep when determining how much to cut from each edge of the photo in order to achieve the requested pixel size. If using auto-gravity and the requested pixel size is larger than the coordinates of the detected object, other elements of the image that receive priority from `g_auto` may impact what else is included in the photo and where in your resulting image the detected object may be located, meaning that the detected object will not necessarily be the center of the photo.

* When using any of the **fill**-based modes (`c_fill`, `c_lfill`, `c_fill_pad`), the coordinates of the detected object should be retained if any cropping is required after scaling.  If using auto-gravity, other elements of the image that receive priority from `g_auto` may impact what else is included in the photo and where in your resulting image the detected object may be located, meaning that the detected object will not necessarily be the center of the photo.

* When using the **auto** cropping mode (`c_auto`), the crop is focused on the object, but also takes into account more of the whole picture, so gives a more 'zoomed out' result than **thumb**, and **crop** but more 'zoomed in' than **fill**. If the requested dimensions are smaller than the best crop, the result is downscaled. If the requested dimensions are larger than the original image, the result is upscaled.

The following examples show how different your cropping results may be for the same requested object in the gravity, but with different cropping modes. In this case, we take the original photo below and apply `g_auto:camera` and `g_camera` with `fill`, `crop`, `thumb` and `auto` cropping modes.  In all cases, the same width and aspect ratio are requested (`ar_1,w_200`).

Original

&nbsp; 

**g_auto:camera**

c_fill

c_crop

c_thumb

c_auto

 

**g_camera**

c_fill

c_crop

c_thumb

c_auto

 

### Using object-aware cropping for responsive delivery 

You can take advantage of object-aware cropping with various cropping modes to assist in **responsive art direction**.  This means that when you deliver different sized images to different devices, you don't just scale the same image, but rather crop images differently for different sizes, so that the important objects are always highly visible.

For example, you may: 

* deliver a full-size image to large HD screens 
* use `g_auto:[your_important_object]`, or `g_[your_important_object]` with `fill` cropping for medium sized screens 
* use `g_auto:[your_important_object]`, or `g_[your_important_object]` with `thumb` or `auto` cropping for very small screens.

For more details on delivering responsive images, see the [Responsive images](responsive_images) guide.

## Using objects with the zoompan effect

In addition to cropping, the Cloudinary AI Content Analysis add-on allows you to use objects for start and end points of a [zoompan](transformation_reference#e_zoompan) transformation.  

The `zoompan` effect lets you create a video or animated GIF from an image by zooming and panning from one area of the image to another. Use the `from` and/or `to` options with objects as gravity and specify a video or animated image format.

The example below is a seven second MP4 video (`.mp4`) of a model wearing fashionable items, starting zoomed into the hat (`from_(g_hat;zoom_4.5)`), then zooming out and panning to the pants (`to_(g_pants;zoom_1.6)`).
![Zoom and pan from hat to pants](https://res.cloudinary.com/demo/image/upload/e_zoompan:du_7;from_(g_hat;zoom_4.5)

```nodejs
cloudinary.image("e_zoompan:du_7;from_(g_hat;zoom_4.5")
```

```react
new CloudinaryImage("e_zoompan:du_7;from_(g_hat;zoom_4.5");
```

```vue
new CloudinaryImage("e_zoompan:du_7;from_(g_hat;zoom_4.5");
```

```angular
new CloudinaryImage("e_zoompan:du_7;from_(g_hat;zoom_4.5");
```

```js
new CloudinaryImage("e_zoompan:du_7;from_(g_hat;zoom_4.5");
```

```python
CloudinaryImage("e_zoompan:du_7;from_(g_hat;zoom_4.5").image()
```

```php
(new ImageTag('e_zoompan:du_7;from_(g_hat;zoom_4.5'));
```

```java
cloudinary.url().transformation(new Transformation().imageTag("e_zoompan:du_7;from_(g_hat;zoom_4.5");
```

```ruby
cl_image_tag("e_zoompan:du_7;from_(g_hat;zoom_4.5")
```

```csharp
cloudinary.Api.UrlImgUp.BuildImageTag("e_zoompan:du_7;from_(g_hat;zoom_4.5")
```

```dart
cloudinary.image('e_zoompan:du_7;from_(g_hat;zoom_4.5').transformation(Transformation());
```

```swift
imageView.cldSetImage(cloudinary.createUrl().generate("e_zoompan:du_7;from_(g_hat;zoom_4.5")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().generate("e_zoompan:du_7;from_(g_hat;zoom_4.5");
```

```flutter
cloudinary.image('e_zoompan:du_7;from_(g_hat;zoom_4.5').transformation(Transformation());
```

```kotlin
cloudinary.image {
	publicId("e_zoompan:du_7;from_(g_hat;zoom_4.5") 
}.generate()
```

```jquery
$.cloudinary.image("e_zoompan:du_7;from_(g_hat;zoom_4.5")
```

```react_native
new CloudinaryImage("e_zoompan:du_7;from_(g_hat;zoom_4.5");
```;to_(g_pants;zoom_1.6)/c_scale,h_250/q_auto/docs/clothing.mp4 "with_image:false")

  
    
    
    
  
  

## Signed URLs

Cloudinary's dynamic image transformation URLs are powerful tools. However, due to the potential costs of your customers experimenting with dynamic URLs that apply the object-aware cropping algorithm, image transformation add-on URLs are required (by default) to be signed using Cloudinary's authenticated API. Alternatively, you can [eagerly generate](eager_and_incoming_transformations#eager_transformations) the requested derived images using Cloudinary's authenticated API. 

To create a signed delivery URL using SDKs, set the `sign_url` parameter to `true` when building a URL or creating an image tag. 

The following code example applies object-aware cropping to the `skater` image, including a signed Cloudinary URL:

![Code for using  with signed URL](https://res.cloudinary.com/my_cloud/image/upload/s--acvfjq2y--/w_400,ar_1,c_thumb,g_auto:skateboard/Skater.jpg "with_url:false, with_code:true, with_image:false")

The generated Cloudinary URL shown below includes a signature component (`/s--acvfjq2y--/`). Only URLs with a valid signature that matches the requested image transformation will be approved for on-the-fly image transformation and delivery.

```html
https://res.cloudinary.com/my_cloud/image/upload/s--acvfjq2y--/w_400,ar_1,c_thumb,g_auto:skateboard/Skater.jpg
```

For more details on signed URLs, see [Signed delivery URLs](control_access_to_media#enforcement_mechanism_signed_delivery_urls).

> **NOTE**:
>
> You can optionally remove the signed URL default requirement for a particular add-on by selecting that add-on in the **Allow unsigned add-on transformations** section of the **Security** page in the Cloudinary Console Settings.

