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

> Scales a layer to fit or fill its composition

Scales a layer to fill or fit the width and height of the composition that contains it.

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

**layerName** `string | string[]` *required*

Name of the layer to scale. Pass an array of names to scale several layers.

**composition** `string` (default: null)

Name of the composition containing the layer (optional). Without it, layers with this name in every composition of the project are scaled.

**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)

## 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
* The scale is calculated from the layer's size and its composition's size
* If the layer's scale is animated, the first keyframe gets the new scale and the other keyframes keep their scale relative to it


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.