> ## 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.

# Advanced Facial Attributes Detection


[Cloudinary](https://cloudinary.com) provides an add-on for advanced face attribute detection capabilities, fully integrated into Cloudinary's image management and transformation pipeline. With the Advanced Facial Attribute Detection add-on, you can extend the Cloudinary features that involve semantic photo data extraction, image cropping and the positioning of image overlays. When using the Advanced Facial Attribute Detection add-on, your images are further processed and many advanced face attributes are automatically extracted. Cloudinary can then use these additional details to smartly crop, position, rotate and overlay images.

Cloudinary is a cloud-based service that provides an end-to-end image management solution including uploads, storage, transformations, optimizations and delivery, and offers a rich set of image management, transformation, analysis and cropping capabilities.

The Advanced Facial Attribute Detection add-on is an integrated face detection solution that utilizes **[Azure AI Services](https://azure.microsoft.com/en-us/products/ai-services/ai-vision/)**. Azure AI Services provides high precision face location detection with state-of-the-art cloud-based algorithms that can detect up to 64 human faces in an image. The detected faces are returned with rectangles (left, top, width and height) indicating the location of faces in the image in pixels, the exact position details of the eyes, mouth, eyebrows, nose and lips, as well as a series of face related attributes from each face such as pose, gender and age.

As of June 30th 2023, Azure AI Services will be retiring facial recognition capabilities that can be used to try to infer emotional states and identity attributes which, if misused, can subject people to stereotyping, discrimination or unfair denial of services.

The following attributes will no longer be returned - `emotion`, `gender`, `age`, `smile`, `facial_hair`, `hair` and `makeup`.

You can read more about the change and potential impact [here](https://azure.microsoft.com/en-us/blog/responsible-ai-investments-and-safeguards-for-facial-recognition/).

#### Getting started

Before you can use the Advanced Facial Attributes Detection add-on:

* You must have a Cloudinary account. If you don't already have one, you can [sign up](https://cloudinary.com/users/register_free) for a free account. 

* Register for the add-on: make sure you're logged in to your account and then go to the [Add-ons](https://console.cloudinary.com/app/settings/addons) page. For more information about add-on registrations, see [Registering for add-ons](cloudinary_add_ons#registering_for_add_ons).

* Keep in mind that many of the examples on this page use our SDKs. For SDK installation and configuration details, see the relevant [SDK](cloudinary_sdks) guide.
  
* If you're new to Cloudinary, you may want to take a look at the [Developer Kickstart](dev_kickstart) for a hands-on, step-by-step introduction to a variety of features.

## Face attribute detection on upload

The Advanced Facial Attribute Detection add-on is very simple to use. The extensive list of face attributes can be extracted from any photo when calling Cloudinary's upload API and setting the `detection` parameter to `adv_face`. For example, take a look at the following photo that we want to upload to Cloudinary's demo product environment:

![photo to upload](https://res.cloudinary.com/demo/image/upload/coupled.jpg "with_url: false, with_code: false")

When calling Cloudinary's API to upload the photo, the `detection` parameter is added to extract the face attributes in the uploaded photo:

```multi
|ruby
Cloudinary::Uploader.upload("coupled.jpg", 
  detection: "adv_face")

|php_2
$cloudinary->uploadApi()->upload("coupled.jpg", 
  ["detection" => "adv_face"]);

|python
cloudinary.uploader.upload("coupled.jpg",
  detection = "adv_face")
      
|nodejs
cloudinary.v2.uploader
.upload("coupled.jpg", 
  { detection: "adv_face" })
.then(result=>console.log(result)); 
        
|java
cloudinary.uploader().upload("coupled.jpg", 
  ObjectUtils.asMap("detection", "adv_face"));

|csharp
var uploadParams = new ImageUploadParams() 
{
  File = new FileDescription(@"coupled.jpg"),
  Detection = "adv_face"
};
var uploadResult = cloudinary.Upload(uploadParams); 

|go
resp, err := cld.Upload.Upload(ctx, "coupled.jpg", uploader.UploadParams{Detection: "adv_faces"})

|android
MediaManager.get().upload("coupled.jpg")
  .option("detection", "adv_face").dispatch();
      
|swift
let params = CLDUploadRequestParams().setDetection("adv_face")
var mySig = MyFunction(params)  // your own function that returns a signature generated on your backend
params.setSignature(CLDSignature(signature: mySig.signature, timestamp: mySig.timestamp))
let request = cloudinary.createUploader().signedUpload(
  url: "coupled.jpg", params: params)

|curl
curl https://api.cloudinary.com/v1_1/demo/image/upload -X POST -F 'file=@/path/to/coupled.jpg' -F 'detection=adv_face' -F 'timestamp=173719931' -F 'api_key=436464676' -F 'signature=a781d61f86a6f818af'

|cli
cld uploader upload "coupled.jpg" detection="adv_face"
```

> **TIP**:
>
> You can use **upload presets** to centrally define a set of upload options including add-on operations to apply, instead of specifying them in each upload call. You can define multiple upload presets, and apply different presets in different upload scenarios. You can create new upload presets in the **Upload Presets** page of the [Console Settings](https://console.cloudinary.com/app/settings/upload/presets) or using the [upload_presets](admin_api#upload_presets) Admin API method. From the **Upload** page of the Console Settings, you can also select default upload presets to use for image, video, and raw API uploads (respectively) as well as default presets for image, video, and raw uploads performed via the Media Library UI. 
> **Learn more**: [Upload presets](upload_presets)

The JSON snippet below contains an excerpt of the results of applying automatic face attribute detection on the uploaded image. The response includes very detailed information regarding each of the faces that were automatically detected in the photo:

* `bounding_box` - The bounding box surrounding a detected face.
* `smile` - The likelihood that the person is smiling.
* `head_pose` - The way the face is positioned in 3D.
* `gender` - Whether the person is a male or a female.
* `age` - Estimated age of the person.
* `facial_hair` - The likelihood that the person has a moustache, beard, and/or sideburns, respectively.
* `glasses` - Whether the person is wearing glasses.
* `emotion` - The likelihood that the person's expression implies certain emotions.
* `blur` - The amount of blur on the face.
* `exposure` - The photo exposure on the face.
* `noise` - A general and numeric evaluation of the amount of photographic noise on the face.
* `makeup` - Whether the person is wearing eye and/or lip makeup.
* `accessories` - An array of accessory items (if any) detected around the face area, such as headwear, glasses, or mask. 
* `occlusion` - Whether the forehead, eyes, or mouth is blocked, for example by a scarf, hat, or mask.
* `hair` - Information about the hair, including whether the hair is visible in the photo, the likelihood that the person is bald, and the likelihood that the person's hair is a particular color.
* `facial_landmarks` - Exact position details of specific elements of the mouth, eyebrows, eyes, and nose.

```json
{
...
 "info"=>
  {"detection"=>
    {"adv_face"=>
      {"status"=>"complete",
       "data"=>
        [{"bounding_box"=>
           {"top"=>95.0, "left"=>104.0,  "width"=>48.0, "height"=>48.0},
          "attributes"=>
           {"smile"=>0.999,
            "head_pose"=>{"pitch"=>0.0, "roll"=>-7.9, "yaw"=>10.8},
            "gender"=>"male",
            "age"=>55.8,
            "facial_hair"=>{"moustache"=>0.0, "beard"=>0.0, "sideburns"=>0.0},
            "glasses"=>"NoGlasses",
            "emotion"=>
             {"anger"=>0.0,
              "contempt"=>0.0,
              "disgust"=>0.001,
              "fear"=>0.0,
              "happiness"=>0.999,
              "neutral"=>0.0,
              "sadness"=>0.0,
              "surprise"=>0.0},
            "blur"=>{"blurLevel"=>"medium", "value"=>0.41},
            "exposure"=>{"exposureLevel"=>"goodExposure", "value"=>0.66},
            "noise"=>{"noiseLevel"=>"low", "value"=>0.0},
            "makeup"=>{"eyeMakeup"=>false, "lipMakeup"=>false},
            "accessories"=>[],
            "occlusion"=>
             {"foreheadOccluded"=>false,
              "eyeOccluded"=>false,
              "mouthOccluded"=>false},
            "hair"=>
             {"bald"=>0.21,
              "invisible"=>false,
              "hairColor"=>
               [{"color"=>"gray", "confidence"=>0.98},
                {"color"=>"black", "confidence"=>0.67},
                {"color"=>"brown", "confidence"=>0.39},
                {"color"=>"other", "confidence"=>0.38},
                {"color"=>"blond", "confidence"=>0.18},
                {"color"=>"red", "confidence"=>0.12}]}},
          "facial_landmarks"=>
           {"mouth"=>
             {"left"=>{"x"=>118.1, "y"=>132.0},
              "right"=>{"x"=>139.2, "y"=>129.4},
              "under_lip"=>
               {"bottom"=>{"x"=>130.6, "y"=>135.2},
                "top"=>{"x"=>130.2, "y"=>132.2}},
              "upper_lip"=>
               {"bottom"=>{"x"=>130.2, "y"=>129.2},
                "top"=>{"x"=>129.9, "y"=>127.3}}},
            "eyebrow"=>
             {"left_outer"=>{"x"=>105.7, "y"=>108.2},
              "left_inner"=>{"x"=>121.9, "y"=>105.5},
              "right_inner"=>{"x"=>131.6, "y"=>104.4},
              "right_outer"=>{"x"=>145.9, "y"=>104.7}},
            "eye"=>
             {"left_outer"=>{"x"=>111.9, "y"=>111.3},
              "left_top"=>{"x"=>115.5, "y"=>109.3},
              "left_bottom"=>{"x"=>115.6, "y"=>111.6},
              "left_inner"=>{"x"=>119.3, "y"=>110.7},
              "right_inner"=>{"x"=>132.9, "y"=>108.9},
              "right_top"=>{"x"=>136.4, "y"=>107.0},
              "right_bottom"=>{"x"=>136.4, "y"=>109.4},
              "right_outer"=>{"x"=>139.8, "y"=>108.6},
              "left_pupil"=>{"x"=>115.0, "y"=>110.4},
              "right_pupil"=>{"x"=>136.3, "y"=>107.8}},
            "nose"=>
             {"tip"=>{"x"=>130.1, "y"=>119.2},
              "root_left"=>{"x"=>123.5, "y"=>110.4},
              "root_right"=>{"x"=>130.2, "y"=>109.5},
              "left_alar_top"=>{"x"=>122.8, "y"=>117.1},
              "right_alar_top"=>{"x"=>133.1, "y"=>116.1},
              "left_alar_out_tip"=>{"x"=>120.7, "y"=>120.6},
              "right_alar_out_tip"=>{"x"=>136.2, "y"=>119.2}}}},
        {"bounding_box"=>
          {"top"=>148.0, "left"=>144.0, "width"=>43.0, "height"=>43.0},
          "attributes"=>
           {"smile"=>1.0,
            "head_pose"=>{"pitch"=>0.0, "roll"=>-12.6, "yaw"=>-14.9},
            "gender"=>"female",
            "age"=>40.2,
            ...
            ...
            ...
           }
        }
      }]
    }
  }
}
```
## Face attribute detection after uploading

The example above shows how to automatically detect face attributes of photos during their upload process. Alternatively, you can use Cloudinary's Admin API to apply automatic face attribute detection to already uploaded images, based on their public IDs.
The following code sample uses Cloudinary's update API to apply face attribute detection to the uploaded image that has the 'coupled' public ID.

```multi
|ruby
Cloudinary::Api.update("coupled", 
  detection: "adv_face")

|php_2
$cloudinary->uploadApi()->update("coupled", 
  ["detection" => "adv_face"]);

|python
cloudinary.api.update("coupled",
  detection = "adv_face")
      
|nodejs
cloudinary.v2.api
.update("coupled", 
  { detection: "adv_face" })
.then(result=>console.log(result));
        
|java
cloudinary.api().update("coupled", 
  ObjectUtils.asMap("detection", "adv_face"));

|csharp
var updateParams = new UpdateParams("coupled")
{
  Detection = "adv_face"
};
var updateResult = cloudinary.Update(updateParams);

|go
resp, err := cld.Admin.UpdateAsset(ctx, admin.UpdateAssetParams{
    PublicID: "coupled", 
    Detection: "adv_face"})

|cli
cld admin update "coupled" detection="adv_face"
```

The face attributes that were previously extracted either using the 'upload' or 'update' API, are also available using the Admin API's show resource details method:

```multi
|ruby
Cloudinary::Api.resource('coupled')

|php_2
$api->asset("coupled");

|python
cloudinary.api.resource("coupled")

|nodejs
cloudinary.v2.api
.resource('coupled')
.then(result=>console.log(result));

|java
cloudinary.api().resource("coupled", ObjectUtils.emptyMap());

|csharp
var getResourceResult = cloudinary.GetResource(new GetResourceParams("coupled"));

|go
resp, err := cld.Admin.Asset(ctx, admin.AssetParams{PublicID: "coupled"})

|cli
cld admin resource "coupled"
```
## Face detection based cropping

Cloudinary provides a large set of image transformation and cropping options. Based on the position of facial attributes detected by the Advanced Facial Attribute Detection add-on, Cloudinary can crop your images to focus on the detected faces, while providing a large set of image transformation and cropping options when using a Cloudinary delivery URL or calling Cloudinary's image API.

To focus an automatic crop on the detected faces, simply set the `crop` parameter to `thumb`, `fill` or `crop` and the `gravity` parameter to `adv_faces` (set gravity to `adv_face` for focusing on the single largest detected face in the image).

The following code sample creates a 150x150 thumbnail of the `coupled` image that's generated using face-detection based cropping. The `gravity` parameter is set to `adv_faces` while the `crop` mode is set to `thumb`.
![150x150 thumbnail of faces cropped with the Advanced Facial Attribute Detection add-on](https://res.cloudinary.com/demo/image/upload/c_thumb,g_adv_faces,h_150,w_150/coupled.jpg)

```nodejs
cloudinary.image("coupled.jpg", {gravity: "adv_faces", height: 150, width: 150, crop: "thumb"})
```

```react
new CloudinaryImage("coupled.jpg").resize(
  thumbnail()
    .width(150)
    .height(150)
    .gravity(focusOn("advanced_faces"))
);
```

```vue
new CloudinaryImage("coupled.jpg").resize(
  thumbnail()
    .width(150)
    .height(150)
    .gravity(focusOn("advanced_faces"))
);
```

```angular
new CloudinaryImage("coupled.jpg").resize(
  thumbnail()
    .width(150)
    .height(150)
    .gravity(focusOn("advanced_faces"))
);
```

```js
new CloudinaryImage("coupled.jpg").resize(
  thumbnail()
    .width(150)
    .height(150)
    .gravity(focusOn("advanced_faces"))
);
```

```python
CloudinaryImage("coupled.jpg").image(gravity="adv_faces", height=150, width=150, crop="thumb")
```

```php
(new ImageTag('coupled.jpg'))
	->resize(Resize::thumbnail()->width(150)
->height(150)
	->gravity(
	Gravity::focusOn("advanced_faces"))
	);
```

```java
cloudinary.url().transformation(new Transformation().gravity("adv_faces").height(150).width(150).crop("thumb")).imageTag("coupled.jpg");
```

```ruby
cl_image_tag("coupled.jpg", gravity: "adv_faces", height: 150, width: 150, crop: "thumb")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("adv_faces").Height(150).Width(150).Crop("thumb")).BuildImageTag("coupled.jpg")
```

```dart
cloudinary.image('coupled.jpg').transformation(Transformation()
	.resize(Resize.thumbnail().width(150)
.height(150)
	.gravity(
	Gravity.focusOn("advanced_faces"))
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setGravity("adv_faces").setHeight(150).setWidth(150).setCrop("thumb")).generate("coupled.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().gravity("adv_faces").height(150).width(150).crop("thumb")).generate("coupled.jpg");
```

```flutter
cloudinary.image('coupled.jpg').transformation(Transformation()
	.resize(Resize.thumbnail().width(150)
.height(150)
	.gravity(
	Gravity.focusOn("advanced_faces"))
	));
```

```kotlin
cloudinary.image {
	publicId("coupled.jpg")
	 resize(Resize.thumbnail() { width(150)
 height(150)
	 gravity(
	Gravity.focusOn("advanced_faces"))
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("coupled.jpg", {gravity: "adv_faces", height: 150, width: 150, crop: "thumb"})
```

```react_native
new CloudinaryImage("coupled.jpg").resize(
  thumbnail()
    .width(150)
    .height(150)
    .gravity(focusOn("advanced_faces"))
);
```

Alternatively, you can crop an image based on the single most visible face in a photo. The following code sample generates and delivers a 100x100 thumbnail containing a single face. The `gravity` parameter is set to `adv_face` while the `crop` mode is set to `thumb`.

![100x100 thumbnail of a single face cropped with the Advanced Facial Attribute Detection add-on](https://res.cloudinary.com/demo/image/upload/c_thumb,g_adv_face,h_100,w_100/coupled.jpg)

```nodejs
cloudinary.image("coupled.jpg", {gravity: "adv_face", height: 100, width: 100, crop: "thumb"})
```

```react
new CloudinaryImage("coupled.jpg").resize(
  thumbnail()
    .width(100)
    .height(100)
    .gravity(focusOn("advanced_face"))
);
```

```vue
new CloudinaryImage("coupled.jpg").resize(
  thumbnail()
    .width(100)
    .height(100)
    .gravity(focusOn("advanced_face"))
);
```

```angular
new CloudinaryImage("coupled.jpg").resize(
  thumbnail()
    .width(100)
    .height(100)
    .gravity(focusOn("advanced_face"))
);
```

```js
new CloudinaryImage("coupled.jpg").resize(
  thumbnail()
    .width(100)
    .height(100)
    .gravity(focusOn("advanced_face"))
);
```

```python
CloudinaryImage("coupled.jpg").image(gravity="adv_face", height=100, width=100, crop="thumb")
```

```php
(new ImageTag('coupled.jpg'))
	->resize(Resize::thumbnail()->width(100)
->height(100)
	->gravity(
	Gravity::focusOn("advanced_face"))
	);
```

```java
cloudinary.url().transformation(new Transformation().gravity("adv_face").height(100).width(100).crop("thumb")).imageTag("coupled.jpg");
```

```ruby
cl_image_tag("coupled.jpg", gravity: "adv_face", height: 100, width: 100, crop: "thumb")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("adv_face").Height(100).Width(100).Crop("thumb")).BuildImageTag("coupled.jpg")
```

```dart
cloudinary.image('coupled.jpg').transformation(Transformation()
	.resize(Resize.thumbnail().width(100)
.height(100)
	.gravity(
	Gravity.focusOn("advanced_face"))
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setGravity("adv_face").setHeight(100).setWidth(100).setCrop("thumb")).generate("coupled.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().gravity("adv_face").height(100).width(100).crop("thumb")).generate("coupled.jpg");
```

```flutter
cloudinary.image('coupled.jpg').transformation(Transformation()
	.resize(Resize.thumbnail().width(100)
.height(100)
	.gravity(
	Gravity.focusOn("advanced_face"))
	));
```

```kotlin
cloudinary.image {
	publicId("coupled.jpg")
	 resize(Resize.thumbnail() { width(100)
 height(100)
	 gravity(
	Gravity.focusOn("advanced_face"))
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("coupled.jpg", {gravity: "adv_face", height: 100, width: 100, crop: "thumb"})
```

```react_native
new CloudinaryImage("coupled.jpg").resize(
  thumbnail()
    .width(100)
    .height(100)
    .gravity(focusOn("advanced_face"))
);
```

## Face detection with signed URLs

Cloudinary's dynamic image transformation URLs are quite powerful, however, due to the potential costs of users accessing unplanned dynamic URLs with the Advanced Facial Attribute Detection cropping directives, image transformation add-on URLs are required (by default) to be signed using Cloudinary's authenticated API and with the `sign_url` parameter set to `true`.

> **NOTES**:
>
> * You can create dynamic unsigned image transformation URLs based on Advanced Facial Attribute Detection as long as you first extract the face attributes during upload or by using the Admin API.

> * You can optionally remove this default requirement for a particular add-on by selecting it in the **Allow unsigned add-on transformations** section of the **Security** Settings in the Cloudinary Console.

For example, a signed URL and the code to generate it:

[Signed image URL](https://res.cloudinary.com/demo/image/upload/s--vnhlc4WH--/c_thumb,g_adv_face,h_100,w_100/coupled.jpg "with_image: false")

As you can see, the generated Cloudinary URL includes a signature component (`s--vnhlc4WH--`). Only URLs with a valid signature (specific to that transformation) will be approved for on-the-fly image transformation using advanced facial attribute detection.

## Eyes detection based cropping

In addition to face-detection based cropping, Cloudinary can dynamically crop your images based on the position of detected eyes. Simply set the `gravity` parameter to `adv_eyes` (`g_adv_eyes` for URLs) to center the image on the detected eyes. The example below delivers a 100x40 thumbnail centered on the eyes of the woman in the photo.

![Original photo](https://res.cloudinary.com/demo/image/upload/face1.jpg "with_url: false, with_code: false")

![Thumbnail centered on eyes using Advanced Facial Attribute Detection](https://res.cloudinary.com/demo/image/upload/c_thumb,g_adv_eyes,h_40,w_100/face1.jpg)

```nodejs
cloudinary.image("face1.jpg", {gravity: "adv_eyes", height: 40, width: 100, crop: "thumb"})
```

```react
new CloudinaryImage("face1.jpg").resize(
  thumbnail()
    .width(100)
    .height(40)
    .gravity(focusOn(advancedEyes()))
);
```

```vue
new CloudinaryImage("face1.jpg").resize(
  thumbnail()
    .width(100)
    .height(40)
    .gravity(focusOn(advancedEyes()))
);
```

```angular
new CloudinaryImage("face1.jpg").resize(
  thumbnail()
    .width(100)
    .height(40)
    .gravity(focusOn(advancedEyes()))
);
```

```js
new CloudinaryImage("face1.jpg").resize(
  thumbnail()
    .width(100)
    .height(40)
    .gravity(focusOn(advancedEyes()))
);
```

```python
CloudinaryImage("face1.jpg").image(gravity="adv_eyes", height=40, width=100, crop="thumb")
```

```php
(new ImageTag('face1.jpg'))
	->resize(Resize::thumbnail()->width(100)
->height(40)
	->gravity(
	Gravity::focusOn(
	FocusOn::advancedEyes()))
	);
```

```java
cloudinary.url().transformation(new Transformation().gravity("adv_eyes").height(40).width(100).crop("thumb")).imageTag("face1.jpg");
```

```ruby
cl_image_tag("face1.jpg", gravity: "adv_eyes", height: 40, width: 100, crop: "thumb")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("adv_eyes").Height(40).Width(100).Crop("thumb")).BuildImageTag("face1.jpg")
```

```dart
cloudinary.image('face1.jpg').transformation(Transformation()
	.resize(Resize.thumbnail().width(100)
.height(40)
	.gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setGravity("adv_eyes").setHeight(40).setWidth(100).setCrop("thumb")).generate("face1.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().gravity("adv_eyes").height(40).width(100).crop("thumb")).generate("face1.jpg");
```

```flutter
cloudinary.image('face1.jpg').transformation(Transformation()
	.resize(Resize.thumbnail().width(100)
.height(40)
	.gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	));
```

```kotlin
cloudinary.image {
	publicId("face1.jpg")
	 resize(Resize.thumbnail() { width(100)
 height(40)
	 gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("face1.jpg", {gravity: "adv_eyes", height: 40, width: 100, crop: "thumb"})
```

```react_native
new CloudinaryImage("face1.jpg").resize(
  thumbnail()
    .width(100)
    .height(40)
    .gravity(focusOn(advancedEyes()))
);
```

## Eyes detection for accurate red eye removal

Cloudinary's rich [transformation capabilities](https://cloudinary.com/features/image_transformation) already allow you to automate red eye removal by setting the `effect` parameter to `redeye` (`e_redeye` for URLs). This enables smart red eye removal algorithms to be automatically applied on the fly to uploaded images. 

In order to get even better quality results, you can use Cloudinary's Advanced Facial Attribute Detection add-on for eye detection together with the red eye removal effect. The add-on can automatically detect where eyes are located in a photo and then the red eye removal algorithm can be applied in a more precise way: simply set the `effect` parameter to `adv_redeye` (`e_adv_redeye` for URLs). 

For example, an image named `redeye` was uploaded to Cloudinary. A cropped 300x80 thumbnail of the photo centered on the eyes only for illustration is displayed below:
![redeye example photo](https://res.cloudinary.com/demo/image/upload/c_thumb,g_adv_eyes,h_80,w_300/redeye.jpg)

```nodejs
cloudinary.image("redeye.jpg", {gravity: "adv_eyes", height: 80, width: 300, crop: "thumb"})
```

```react
new CloudinaryImage("redeye.jpg").resize(
  thumbnail()
    .width(300)
    .height(80)
    .gravity(focusOn(advancedEyes()))
);
```

```vue
new CloudinaryImage("redeye.jpg").resize(
  thumbnail()
    .width(300)
    .height(80)
    .gravity(focusOn(advancedEyes()))
);
```

```angular
new CloudinaryImage("redeye.jpg").resize(
  thumbnail()
    .width(300)
    .height(80)
    .gravity(focusOn(advancedEyes()))
);
```

```js
new CloudinaryImage("redeye.jpg").resize(
  thumbnail()
    .width(300)
    .height(80)
    .gravity(focusOn(advancedEyes()))
);
```

```python
CloudinaryImage("redeye.jpg").image(gravity="adv_eyes", height=80, width=300, crop="thumb")
```

```php
(new ImageTag('redeye.jpg'))
	->resize(Resize::thumbnail()->width(300)
->height(80)
	->gravity(
	Gravity::focusOn(
	FocusOn::advancedEyes()))
	);
```

```java
cloudinary.url().transformation(new Transformation().gravity("adv_eyes").height(80).width(300).crop("thumb")).imageTag("redeye.jpg");
```

```ruby
cl_image_tag("redeye.jpg", gravity: "adv_eyes", height: 80, width: 300, crop: "thumb")
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("adv_eyes").Height(80).Width(300).Crop("thumb")).BuildImageTag("redeye.jpg")
```

```dart
cloudinary.image('redeye.jpg').transformation(Transformation()
	.resize(Resize.thumbnail().width(300)
.height(80)
	.gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setGravity("adv_eyes").setHeight(80).setWidth(300).setCrop("thumb")).generate("redeye.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation().gravity("adv_eyes").height(80).width(300).crop("thumb")).generate("redeye.jpg");
```

```flutter
cloudinary.image('redeye.jpg').transformation(Transformation()
	.resize(Resize.thumbnail().width(300)
.height(80)
	.gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	));
```

```kotlin
cloudinary.image {
	publicId("redeye.jpg")
	 resize(Resize.thumbnail() { width(300)
 height(80)
	 gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("redeye.jpg", {gravity: "adv_eyes", height: 80, width: 300, crop: "thumb"})
```

```react_native
new CloudinaryImage("redeye.jpg").resize(
  thumbnail()
    .width(300)
    .height(80)
    .gravity(focusOn(advancedEyes()))
);
```

Adding the redeye effect parameter and setting its value to `adv_redeye` delivers the following image:

![photo after applying the adv_redeye effect](https://res.cloudinary.com/demo/image/upload/e_adv_redeye/c_thumb,g_adv_eyes,h_80,w_300/redeye.jpg)

```nodejs
cloudinary.image("redeye.jpg", {transformation: [
  {effect: "adv_redeye"},
  {gravity: "adv_eyes", height: 80, width: 300, crop: "thumb"}
  ]})
```

```react
new CloudinaryImage("redeye.jpg").effect(advancedRedEye()).resize(
  thumbnail()
    .width(300)
    .height(80)
    .gravity(focusOn(advancedEyes()))
);
```

```vue
new CloudinaryImage("redeye.jpg").effect(advancedRedEye()).resize(
  thumbnail()
    .width(300)
    .height(80)
    .gravity(focusOn(advancedEyes()))
);
```

```angular
new CloudinaryImage("redeye.jpg").effect(advancedRedEye()).resize(
  thumbnail()
    .width(300)
    .height(80)
    .gravity(focusOn(advancedEyes()))
);
```

```js
new CloudinaryImage("redeye.jpg").effect(advancedRedEye()).resize(
  thumbnail()
    .width(300)
    .height(80)
    .gravity(focusOn(advancedEyes()))
);
```

```python
CloudinaryImage("redeye.jpg").image(transformation=[
  {'effect': "adv_redeye"},
  {'gravity': "adv_eyes", 'height': 80, 'width': 300, 'crop': "thumb"}
  ])
```

```php
(new ImageTag('redeye.jpg'))
	->effect(Effect::advancedRedEye())
	->resize(Resize::thumbnail()->width(300)
->height(80)
	->gravity(
	Gravity::focusOn(
	FocusOn::advancedEyes()))
	);
```

```java
cloudinary.url().transformation(new Transformation()
  .effect("adv_redeye").chain()
  .gravity("adv_eyes").height(80).width(300).crop("thumb")).imageTag("redeye.jpg");
```

```ruby
cl_image_tag("redeye.jpg", transformation: [
  {effect: "adv_redeye"},
  {gravity: "adv_eyes", height: 80, width: 300, crop: "thumb"}
  ])
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Effect("adv_redeye").Chain()
  .Gravity("adv_eyes").Height(80).Width(300).Crop("thumb")).BuildImageTag("redeye.jpg")
```

```dart
cloudinary.image('redeye.jpg').transformation(Transformation()
	.effect(Effect.advancedRedEye())
	.resize(Resize.thumbnail().width(300)
.height(80)
	.gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setEffect("adv_redeye").chain()
  .setGravity("adv_eyes").setHeight(80).setWidth(300).setCrop("thumb")).generate("redeye.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation()
  .effect("adv_redeye").chain()
  .gravity("adv_eyes").height(80).width(300).crop("thumb")).generate("redeye.jpg");
```

```flutter
cloudinary.image('redeye.jpg').transformation(Transformation()
	.effect(Effect.advancedRedEye())
	.resize(Resize.thumbnail().width(300)
.height(80)
	.gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	));
```

```kotlin
cloudinary.image {
	publicId("redeye.jpg")
	 effect(Effect.advancedRedEye())
	 resize(Resize.thumbnail() { width(300)
 height(80)
	 gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("redeye.jpg", {transformation: [
  {effect: "adv_redeye"},
  {gravity: "adv_eyes", height: 80, width: 300, crop: "thumb"}
  ]})
```

```react_native
new CloudinaryImage("redeye.jpg").effect(advancedRedEye()).resize(
  thumbnail()
    .width(300)
    .height(80)
    .gravity(focusOn(advancedEyes()))
);
```

## Face overlays

The extracted facial attribute details also include the pose of the detected face, which allows Cloudinary to not only position overlays on top of detected faces, but also to rotate and scale the overlays accordingly for exact positioning over the underlying face. This is easily accomplished by setting the `gravity` parameter of the added overlay to `adv_faces`. 

For example, the following PNG image named `silver_face_mask` was uploaded to Cloudinary:

![silver mask](https://res.cloudinary.com/demo/image/upload/silver_face_mask.png "with_url: false, with_code: false, thumb: w_80")

To smartly overlay the mask image on top of all detected faces in the `coupled` image, the `overlay` parameter is set to the ID of the mask image and the `gravity` parameter is set to `adv_faces`. In addition, we set the `region_relative` flag together with a `1.1` width, which means that each overlay will be scaled to 110% of the width of the detected face.

![mask overlaid coupled.jpg](https://res.cloudinary.com/demo/image/upload/l_silver_face_mask/c_scale,fl_region_relative,w_1.1/fl_layer_apply,g_adv_faces/coupled.jpg)

```nodejs
cloudinary.image("coupled.jpg", {transformation: [
  {overlay: "silver_face_mask"},
  {flags: "region_relative", width: "1.1", crop: "scale"},
  {flags: "layer_apply", gravity: "adv_faces"}
  ]})
```

```react
new CloudinaryImage("coupled.jpg").overlay(
  source(
    image("silver_face_mask").transformation(
      new Transformation().resize(scale().width(1.1).regionRelative())
    )
  ).position(new Position().gravity(focusOn("advanced_faces")))
);
```

```vue
new CloudinaryImage("coupled.jpg").overlay(
  source(
    image("silver_face_mask").transformation(
      new Transformation().resize(scale().width(1.1).regionRelative())
    )
  ).position(new Position().gravity(focusOn("advanced_faces")))
);
```

```angular
new CloudinaryImage("coupled.jpg").overlay(
  source(
    image("silver_face_mask").transformation(
      new Transformation().resize(scale().width(1.1).regionRelative())
    )
  ).position(new Position().gravity(focusOn("advanced_faces")))
);
```

```js
new CloudinaryImage("coupled.jpg").overlay(
  source(
    image("silver_face_mask").transformation(
      new Transformation().resize(scale().width(1.1).regionRelative())
    )
  ).position(new Position().gravity(focusOn("advanced_faces")))
);
```

```python
CloudinaryImage("coupled.jpg").image(transformation=[
  {'overlay': "silver_face_mask"},
  {'flags': "region_relative", 'width': "1.1", 'crop': "scale"},
  {'flags': "layer_apply", 'gravity': "adv_faces"}
  ])
```

```php
(new ImageTag('coupled.jpg'))
	->overlay(Overlay::source(
	Source::image("silver_face_mask")
	->transformation((new Transformation())
	->resize(Resize::scale()->width(1.1)
	->regionRelative()
	))
	)
	->position((new Position())
	->gravity(
	Gravity::focusOn("advanced_faces"))
	)
	);
```

```java
cloudinary.url().transformation(new Transformation()
  .overlay(new Layer().publicId("silver_face_mask")).chain()
  .flags("region_relative").width(1.1).crop("scale").chain()
  .flags("layer_apply").gravity("adv_faces")).imageTag("coupled.jpg");
```

```ruby
cl_image_tag("coupled.jpg", transformation: [
  {overlay: "silver_face_mask"},
  {flags: "region_relative", width: 1.1, crop: "scale"},
  {flags: "layer_apply", gravity: "adv_faces"}
  ])
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Overlay(new Layer().PublicId("silver_face_mask")).Chain()
  .Flags("region_relative").Width(1.1).Crop("scale").Chain()
  .Flags("layer_apply").Gravity("adv_faces")).BuildImageTag("coupled.jpg")
```

```dart
cloudinary.image('coupled.jpg').transformation(Transformation()
	.overlay(Overlay.source(
	Source.image("silver_face_mask")
	.transformation(new Transformation()
	.resize(Resize.scale().width(1.1)
	.regionRelative()
	))
	)
	.position(Position()
	.gravity(
	Gravity.focusOn("advanced_faces"))
	)
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setOverlay("silver_face_mask").chain()
  .setFlags("region_relative").setWidth(1.1).setCrop("scale").chain()
  .setFlags("layer_apply").setGravity("adv_faces")).generate("coupled.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation()
  .overlay(new Layer().publicId("silver_face_mask")).chain()
  .flags("region_relative").width(1.1).crop("scale").chain()
  .flags("layer_apply").gravity("adv_faces")).generate("coupled.jpg");
```

```flutter
cloudinary.image('coupled.jpg').transformation(Transformation()
	.overlay(Overlay.source(
	Source.image("silver_face_mask")
	.transformation(new Transformation()
	.resize(Resize.scale().width(1.1)
	.regionRelative()
	))
	)
	.position(Position()
	.gravity(
	Gravity.focusOn("advanced_faces"))
	)
	));
```

```kotlin
cloudinary.image {
	publicId("coupled.jpg")
	 overlay(Overlay.source(
	Source.image("silver_face_mask") {
	 transformation(Transformation {
	 resize(Resize.scale() { width(1.1F)
	 regionRelative()
	 }) })
	 }) {
	 position(Position() {
	 gravity(
	Gravity.focusOn("advanced_faces"))
	 })
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("coupled.jpg", {transformation: [
  {overlay: new cloudinary.Layer().publicId("silver_face_mask")},
  {flags: "region_relative", width: "1.1", crop: "scale"},
  {flags: "layer_apply", gravity: "adv_faces"}
  ]})
```

```react_native
new CloudinaryImage("coupled.jpg").overlay(
  source(
    image("silver_face_mask").transformation(
      new Transformation().resize(scale().width(1.1).regionRelative())
    )
  ).position(new Position().gravity(focusOn("advanced_faces")))
);
```

## Eyes overlays

As described above, the Advanced Facial Attribute Detection add-on detects specific facial attributes, including the exact position of the eyes of each face in a photo. Based on this information, Cloudinary can position overlays on top of all the detected eye pairs in an image.

For example, the following PNG image named `glasses` was uploaded to Cloudinary:

![image of glasses](https://res.cloudinary.com/demo/image/upload/glasses.jpg "with_url: false, with_code: false, thumb: w_200")

In order to smartly overlay the glasses on top of all detected eye pairs in an uploaded image, the `overlay` parameter is set to the ID of the glasses image and the `gravity` parameter is set to `adv_eyes`. In addition, we set the `region_relative` flag together with a `1.5` width, which means that each overlay should be scaled to 150% of the detected eyes.

![glasses added to auto detected eyes of all faces in the image](https://res.cloudinary.com/demo/image/upload/l_glasses/c_scale,fl_region_relative,w_1.5/fl_layer_apply,g_adv_eyes/coupled.jpg)

```nodejs
cloudinary.image("coupled.jpg", {transformation: [
  {overlay: "glasses"},
  {flags: "region_relative", width: "1.5", crop: "scale"},
  {flags: "layer_apply", gravity: "adv_eyes"}
  ]})
```

```react
new CloudinaryImage("coupled.jpg").overlay(
  source(
    image("glasses").transformation(
      new Transformation().resize(scale().width(1.5).regionRelative())
    )
  ).position(new Position().gravity(focusOn(advancedEyes())))
);
```

```vue
new CloudinaryImage("coupled.jpg").overlay(
  source(
    image("glasses").transformation(
      new Transformation().resize(scale().width(1.5).regionRelative())
    )
  ).position(new Position().gravity(focusOn(advancedEyes())))
);
```

```angular
new CloudinaryImage("coupled.jpg").overlay(
  source(
    image("glasses").transformation(
      new Transformation().resize(scale().width(1.5).regionRelative())
    )
  ).position(new Position().gravity(focusOn(advancedEyes())))
);
```

```js
new CloudinaryImage("coupled.jpg").overlay(
  source(
    image("glasses").transformation(
      new Transformation().resize(scale().width(1.5).regionRelative())
    )
  ).position(new Position().gravity(focusOn(advancedEyes())))
);
```

```python
CloudinaryImage("coupled.jpg").image(transformation=[
  {'overlay': "glasses"},
  {'flags': "region_relative", 'width': "1.5", 'crop': "scale"},
  {'flags': "layer_apply", 'gravity': "adv_eyes"}
  ])
```

```php
(new ImageTag('coupled.jpg'))
	->overlay(Overlay::source(
	Source::image("glasses")
	->transformation((new Transformation())
	->resize(Resize::scale()->width(1.5)
	->regionRelative()
	))
	)
	->position((new Position())
	->gravity(
	Gravity::focusOn(
	FocusOn::advancedEyes()))
	)
	);
```

```java
cloudinary.url().transformation(new Transformation()
  .overlay(new Layer().publicId("glasses")).chain()
  .flags("region_relative").width(1.5).crop("scale").chain()
  .flags("layer_apply").gravity("adv_eyes")).imageTag("coupled.jpg");
```

```ruby
cl_image_tag("coupled.jpg", transformation: [
  {overlay: "glasses"},
  {flags: "region_relative", width: 1.5, crop: "scale"},
  {flags: "layer_apply", gravity: "adv_eyes"}
  ])
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Overlay(new Layer().PublicId("glasses")).Chain()
  .Flags("region_relative").Width(1.5).Crop("scale").Chain()
  .Flags("layer_apply").Gravity("adv_eyes")).BuildImageTag("coupled.jpg")
```

```dart
cloudinary.image('coupled.jpg').transformation(Transformation()
	.overlay(Overlay.source(
	Source.image("glasses")
	.transformation(new Transformation()
	.resize(Resize.scale().width(1.5)
	.regionRelative()
	))
	)
	.position(Position()
	.gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	)
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setOverlay("glasses").chain()
  .setFlags("region_relative").setWidth(1.5).setCrop("scale").chain()
  .setFlags("layer_apply").setGravity("adv_eyes")).generate("coupled.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation()
  .overlay(new Layer().publicId("glasses")).chain()
  .flags("region_relative").width(1.5).crop("scale").chain()
  .flags("layer_apply").gravity("adv_eyes")).generate("coupled.jpg");
```

```flutter
cloudinary.image('coupled.jpg').transformation(Transformation()
	.overlay(Overlay.source(
	Source.image("glasses")
	.transformation(new Transformation()
	.resize(Resize.scale().width(1.5)
	.regionRelative()
	))
	)
	.position(Position()
	.gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	)
	));
```

```kotlin
cloudinary.image {
	publicId("coupled.jpg")
	 overlay(Overlay.source(
	Source.image("glasses") {
	 transformation(Transformation {
	 resize(Resize.scale() { width(1.5F)
	 regionRelative()
	 }) })
	 }) {
	 position(Position() {
	 gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	 })
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("coupled.jpg", {transformation: [
  {overlay: new cloudinary.Layer().publicId("glasses")},
  {flags: "region_relative", width: "1.5", crop: "scale"},
  {flags: "layer_apply", gravity: "adv_eyes"}
  ]})
```

```react_native
new CloudinaryImage("coupled.jpg").overlay(
  source(
    image("glasses").transformation(
      new Transformation().resize(scale().width(1.5).regionRelative())
    )
  ).position(new Position().gravity(focusOn(advancedEyes())))
);
```

In another example, the following PNG image named `harlequinmask` was uploaded to Cloudinary:

![harlequinmask](https://res.cloudinary.com/demo/image/upload/harlequinmask.jpg "with_url: false, with_code: false, thumb: w_200")

To smartly overlay the mask on top of all the detected eye pairs in the uploaded image `cloudinary_team`, the `overlay` parameter is set to the ID of the `harlequinmask` image and the `gravity` parameter is set to `adv_eyes`. We also set the `region_relative` flag together with a `1.7` width to scale the overlay to 170% of the width of the detected eyes, and resize the image to an oval thumbnail with a width of 700 pixels.

![add a mask overlay on the eyes of everyone in the image](https://res.cloudinary.com/demo/image/upload/c_scale,w_700/r_max/l_harlequinmask/c_scale,fl_region_relative,w_1.7/fl_layer_apply,g_adv_eyes/cloudinary_team.jpg)

```nodejs
cloudinary.image("cloudinary_team.jpg", {transformation: [
  {width: 700, crop: "scale"},
  {radius: "max"},
  {overlay: "harlequinmask"},
  {flags: "region_relative", width: "1.7", crop: "scale"},
  {flags: "layer_apply", gravity: "adv_eyes"}
  ]})
```

```react
new CloudinaryImage("cloudinary_team.jpg")
  .resize(scale().width(700))
  .roundCorners(max())
  .overlay(
    source(
      image("harlequinmask").transformation(
        new Transformation().resize(scale().width(1.7).regionRelative())
      )
    ).position(new Position().gravity(focusOn(advancedEyes())))
  );
```

```vue
new CloudinaryImage("cloudinary_team.jpg")
  .resize(scale().width(700))
  .roundCorners(max())
  .overlay(
    source(
      image("harlequinmask").transformation(
        new Transformation().resize(scale().width(1.7).regionRelative())
      )
    ).position(new Position().gravity(focusOn(advancedEyes())))
  );
```

```angular
new CloudinaryImage("cloudinary_team.jpg")
  .resize(scale().width(700))
  .roundCorners(max())
  .overlay(
    source(
      image("harlequinmask").transformation(
        new Transformation().resize(scale().width(1.7).regionRelative())
      )
    ).position(new Position().gravity(focusOn(advancedEyes())))
  );
```

```js
new CloudinaryImage("cloudinary_team.jpg")
  .resize(scale().width(700))
  .roundCorners(max())
  .overlay(
    source(
      image("harlequinmask").transformation(
        new Transformation().resize(scale().width(1.7).regionRelative())
      )
    ).position(new Position().gravity(focusOn(advancedEyes())))
  );
```

```python
CloudinaryImage("cloudinary_team.jpg").image(transformation=[
  {'width': 700, 'crop': "scale"},
  {'radius': "max"},
  {'overlay': "harlequinmask"},
  {'flags': "region_relative", 'width': "1.7", 'crop': "scale"},
  {'flags': "layer_apply", 'gravity': "adv_eyes"}
  ])
```

```php
(new ImageTag('cloudinary_team.jpg'))
	->resize(Resize::scale()->width(700))
	->roundCorners(RoundCorners::max())
	->overlay(Overlay::source(
	Source::image("harlequinmask")
	->transformation((new Transformation())
	->resize(Resize::scale()->width(1.7)
	->regionRelative()
	))
	)
	->position((new Position())
	->gravity(
	Gravity::focusOn(
	FocusOn::advancedEyes()))
	)
	);
```

```java
cloudinary.url().transformation(new Transformation()
  .width(700).crop("scale").chain()
  .radius("max").chain()
  .overlay(new Layer().publicId("harlequinmask")).chain()
  .flags("region_relative").width(1.7).crop("scale").chain()
  .flags("layer_apply").gravity("adv_eyes")).imageTag("cloudinary_team.jpg");
```

```ruby
cl_image_tag("cloudinary_team.jpg", transformation: [
  {width: 700, crop: "scale"},
  {radius: "max"},
  {overlay: "harlequinmask"},
  {flags: "region_relative", width: 1.7, crop: "scale"},
  {flags: "layer_apply", gravity: "adv_eyes"}
  ])
```

```csharp
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(700).Crop("scale").Chain()
  .Radius("max").Chain()
  .Overlay(new Layer().PublicId("harlequinmask")).Chain()
  .Flags("region_relative").Width(1.7).Crop("scale").Chain()
  .Flags("layer_apply").Gravity("adv_eyes")).BuildImageTag("cloudinary_team.jpg")
```

```dart
cloudinary.image('cloudinary_team.jpg').transformation(Transformation()
	.resize(Resize.scale().width(700))
	.roundCorners(RoundCorners.max())
	.overlay(Overlay.source(
	Source.image("harlequinmask")
	.transformation(new Transformation()
	.resize(Resize.scale().width(1.7)
	.regionRelative()
	))
	)
	.position(Position()
	.gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	)
	));
```

```swift
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(700).setCrop("scale").chain()
  .setRadius("max").chain()
  .setOverlay("harlequinmask").chain()
  .setFlags("region_relative").setWidth(1.7).setCrop("scale").chain()
  .setFlags("layer_apply").setGravity("adv_eyes")).generate("cloudinary_team.jpg")!, cloudinary: cloudinary)
```

```android
MediaManager.get().url().transformation(new Transformation()
  .width(700).crop("scale").chain()
  .radius("max").chain()
  .overlay(new Layer().publicId("harlequinmask")).chain()
  .flags("region_relative").width(1.7).crop("scale").chain()
  .flags("layer_apply").gravity("adv_eyes")).generate("cloudinary_team.jpg");
```

```flutter
cloudinary.image('cloudinary_team.jpg').transformation(Transformation()
	.addTransformation("c_scale,w_700/r_max/l_harlequinmask/c_scale,fl_region_relative,w_1.7/fl_layer_apply,g_adv_eyes"));
```

```kotlin
cloudinary.image {
	publicId("cloudinary_team.jpg")
	 resize(Resize.scale() { width(700) })
	 roundCorners(RoundCorners.max())
	 overlay(Overlay.source(
	Source.image("harlequinmask") {
	 transformation(Transformation {
	 resize(Resize.scale() { width(1.7F)
	 regionRelative()
	 }) })
	 }) {
	 position(Position() {
	 gravity(
	Gravity.focusOn(
	FocusOn.advancedEyes()))
	 })
	 }) 
}.generate()
```

```jquery
$.cloudinary.image("cloudinary_team.jpg", {transformation: [
  {width: 700, crop: "scale"},
  {radius: "max"},
  {overlay: new cloudinary.Layer().publicId("harlequinmask")},
  {flags: "region_relative", width: "1.7", crop: "scale"},
  {flags: "layer_apply", gravity: "adv_eyes"}
  ]})
```

```react_native
new CloudinaryImage("cloudinary_team.jpg")
  .resize(scale().width(700))
  .roundCorners(max())
  .overlay(
    source(
      image("harlequinmask").transformation(
        new Transformation().resize(scale().width(1.7).regionRelative())
      )
    ).position(new Position().gravity(focusOn(advancedEyes())))
  );
```

For a full list of additional Cloudinary's image transformation options, see [Image transformations](image_transformations).
