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

# nx:layer-autoscale

> Automatically scales a layer to fit or fill the composition

Automatically scales a layer to perfectly fit or fill your composition dimensions. Choose between different scaling behaviors to achieve the exact look you want.

## Examples

### Fill scaling (default)

```json theme={null}
{
  "type": "function",
  "name": "nx:layer-autoscale",
  "params": {
    "layerName": "Background Image",
    "type": "fill"
  }
}
```

### Fit scaling

```json theme={null}
{
  "type": "function",
  "name": "nx:layer-autoscale",
  "params": {
    "layerName": "Logo",
    "type": "fit"
  }
}
```

### Target specific composition

```json theme={null}
{
  "type": "function",
  "name": "nx:layer-autoscale",
  "params": {
    "composition": "Main Comp",
    "layerName": "Product Image",
    "type": "fill"
  }
}
```

## Parameters

<ParamField path="layerName" type="string" required>
  Name of the layer to scale
</ParamField>

<ParamField path="composition" type="string" default="null">
  Name/ID of the composition containing the layer (optional)
</ParamField>

<ParamField path="type" type="string" default="fill">
  Scaling behavior:

  * `"fill"` - Scale to fill the composition (may crop content)
  * `"fit"` - Scale to fit within the composition (maintains aspect ratio)
</ParamField>

## Scaling Behavior

* **Fill**: Scales the layer to cover the entire composition (may crop content to maintain aspect ratio)
* **Fit**: Scales the layer to fit completely within the composition (entire layer remains visible)
* Maintains the original aspect ratio of the layer
* Automatically calculates the optimal scale value
