# Object

## Product image

AI Background API supports several options to provide source images that need to be processed.

{% hint style="info" %}
You have to upload **only** **images** **without background**, so you can use Claid API [Background Removal](https://docs.claid.ai/image-editing-api/image-operations/background#background-removal).&#x20;

If you choose to upload an image with a background, the scene will be created around the entire image.
{% endhint %}

#### HTTP(S) URL

URL of the input image should be from 1 to 4096 characters. The image must be accessible by our system.

```json
{
    "object": {
        "image_url": "https://images.claid.ai/photoshoot-templates/docs/product.png"
    }
}
```

#### Connected storage

You can connect [Cloud Storage](https://docs.claid.ai/storage-connectors) and use it as a source for images. Currently, our API supports AWS S3 and Google Cloud Storage.

After connecting your Cloud Storage, you can refer the storage name as an input.

```json
{
    "object": {
        "image_url": "storage://storage-name/path/image.png"
    }
}
```

#### Input image file types

The API supports the following image formats as inputs: BMP, GIF, JPEG, PNG, TIFF, WEBP, AVIF, and HEIC.&#x20;

{% hint style="info" %}
JPEG does not support background transparency, so you will probably want to select another image format.
{% endhint %}

## Placement

There are several placement types that can be used to position an object in a scene. Some of them allow additional parameters for a more accurate positioning.

<table data-full-width="false"><thead><tr><th width="239">Placement type</th><th>Description</th></tr></thead><tbody><tr><td><code>"absolute"</code></td><td><a data-mention href="#absolute-placement">#absolute-placement</a> type allows to manually define a product position based on dependent parameters such as <code>position</code>, <code>scale</code>, and <code>rotation_degree</code>. It is used <strong>by default</strong>.</td></tr><tr><td><code>"original"</code></td><td><a data-mention href="#original-placement">#original-placement</a> type keeps the product's position on the generated images the same as it was on the input images.</td></tr></tbody></table>

### Absolute placement

Absolute placement is a method to manually tune an object position using one or multiple dependent fields: [#position](#position "mention"), [#scale](#scale "mention"), and [#rotation-degree](#rotation-degree "mention"). It is used by default so that `placement_type` field can be omitted or specified explicitly.

```json
{
    "object": {
        "image_url": "storage://storage-name/path/image.png",
        "placement_type": "absolute",
        "position": {
            "x":0.6, 
            "y":0.4
        },
        "scale": 0.4,
        "rotation_degree": 90.0
    }
}
```

#### Rotation degree

You can do 360-degree rotation of the object by specifying the `rotation_degree` option.

The object will rotate in a clockwise direction from `0` to `360` degrees.

```json
{
    "object": {
        "image_url": "storage://storage-name/path/image.png",
        "rotation_degree": 90.0
    }
}
```

#### Scale

You can change the size of the object in relation to the background by specifying the `scale` option.

By default, the object is scaled to the edges of the generated background, which is equivalent to setting `scale` to `1.0`.

If you wish, the object can be scaled down to 10% of the total width and height of the generated background, which is equivalent to setting `scale` to `0.1`.

```json
{
    "object": {
        "image_url": "storage://storage-name/path/image.png",
        "scale": 0.4
    }
}
```

#### Position

You can move the object around the image by specifying relative object position with `position` option.

By default, the object is positioned at the center of the image, which corresponds to `{"x":0.5, "y":0.5}`.

Positioning is not an intuitive concept, so below is a reference table for positioning the object:

| <p>left top corner:</p><p><code>"x":</code><strong><code>0.0</code></strong><code>, "y":</code><strong><code>0.0</code></strong></p>    | <p>top edge:</p><p><code>"x":</code><strong><code>0.5</code></strong><code>, "y":</code><strong><code>0.0</code></strong></p>    | <p>right top corner:</p><p><code>"x":</code><strong><code>1.0</code></strong><code>, "y":</code><strong><code>0.0</code></strong></p>    |
| --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| <p>left edge:</p><p><code>"x":</code><strong><code>0.0</code></strong><code>, "y":</code><strong><code>0.5</code></strong></p>          | <p>center:</p><p><code>"x":</code><strong><code>0.5</code></strong><code>, "y":</code><strong><code>0.5</code></strong></p>      | <p>right edge:</p><p><code>"x":</code><strong><code>1.0</code></strong><code>, "y":</code><strong><code>0.5</code></strong></p>          |
| <p>left bottom corner:</p><p><code>"x":</code><strong><code>0.0</code></strong><code>, "y":</code><strong><code>1.0</code></strong></p> | <p>bottom edge:</p><p><code>"x":</code><strong><code>0.5</code></strong><code>, "y":</code><strong><code>1.0</code></strong></p> | <p>right bottom corner:</p><p><code>"x":</code><strong><code>1.0</code></strong><code>, "y":</code><strong><code>1.0</code></strong></p> |

```json
{
    "object": {
        "image_url": "storage://storage-name/path/image.png",
        "position": {
            "x":0.6, 
            "y":0.4
        }
    }
}
```

#### Possible values

<table><thead><tr><th width="244">Parameter</th><th>Type</th><th>Range</th><th>Default value</th></tr></thead><tbody><tr><td><code>image_url</code></td><td>str</td><td>1 - 4096</td><td><strong>is required</strong></td></tr><tr><td><code>rotation_degree</code></td><td>float</td><td>0.0 - 360.0</td><td>0.0</td></tr><tr><td><code>scale</code></td><td>float</td><td>0.0 - 1.0</td><td>1.0</td></tr><tr><td><code>position.x</code></td><td>float</td><td>0.0 - 1.0</td><td>0.5</td></tr><tr><td><code>position.y</code></td><td>float</td><td>0.0 - 1.0</td><td>0.5</td></tr></tbody></table>

### Original placement

Original placement is a choice when a product on the original image with a transparent background is already has a desired position. Meaning, background will be generated, while the product will remain in the same place as it was on the original image.

This placement type doesn't require any additional fields.

```json
{
    "object": {
        "image_url": "storage://storage-name/path/image.png",
        "placement_type": "original"
    }
}
```
