# Clamp

> Clamp channel values to a range.

| Node | Clamp |
|---|---|
| Menu | Color › Clamp |
| **Names in each format** | |
| .oink comp (JSON) | `"type": "OC_N_clamp"` |
| .nk script | `Clamp` ([how .nk import works](/docs/nuke-users/nk-import)) |
| Python | `nuke.createNode("Clamp")` |
| Assistant (MCP) | `create_node(type="Clamp")` |
| Tab search | `clamp` |

![Clamp properties](/shots/nodes/clamp@2x.webp)

## Inputs and outputs

| Port | Name | Type |
|---|---|---|
| input 0 | Image | image |
| input 1 | mask | image |
| output 0 | Image | image |

## Knobs

Panel tab **Clamp**, in panel order.

| Knob | Label | Type | Default | Range / values | .nk knob | Description |
|---|---|---|---|---|---|---|
| `channels` | channels | menu | `all` | rgba, rgb, alpha, all, none |  | Layer the op applies to: rgb, rgba, alpha, all, none, <layer> or <layer>.<ch> |
| `minimum` | minimum | colour ×4 | `0, 0, 0, 0` | 0 to 1 | `minimum` |  |
| `minimum_enable` | enable minimum | bool | `true` |  | `minimum_enable` |  |
| `maximum` | maximum | colour ×4 | `1, 1, 1, 1` | 0 to 1 | `maximum` |  |
| `maximum_enable` | enable maximum | bool | `true` |  | `maximum_enable` |  |
| `MinClampTo` | MinClampTo | colour ×4 | `0, 0, 0, 0` | 0 to 1 | `MinClampTo` |  |
| `MinClampTo_enable` | enable MinClampTo | bool | `false` |  | `MinClampTo_enable` |  |
| `MaxClampTo` | MaxClampTo | colour ×4 | `1, 1, 1, 1` | 0 to 1 | `MaxClampTo` |  |
| `MaxClampTo_enable` | enable MaxClampTo | bool | `false` |  | `MaxClampTo_enable` |  |
| `mask_channel` | mask | menu | `none` | none, rgba.alpha, rgba.red, rgba.green, rgba.blue |  | Mask channel, e.g. rgba.alpha (none = no mask) |
| `inject` | inject | bool | `false` |  |  | Copy the mask into mask.a for nodes downstream |
| `invert_mask` | invert | bool | `false` |  | `invert_mask` |  |
| `fringe` | fringe | bool | `false` |  |  | Only apply the effect at the edges of the mask |
| `unpremult` | (un)premult by | menu | `none` | none, rgba.alpha |  |  |
| `invert_unpremult` | invert | bool | `false` |  |  | (Un)premultiply by 1 - alpha |
| `mix` | mix | float | `1` | 0 to 1 | `mix` |  |

### Other knobs (Python, .nk and the assistant; not on the panel)

| Knob | Label | Type | Default | Range / values | .nk knob | Description |
|---|---|---|---|---|---|---|
| `gl_color` | Viewer Controls Color | float ×3 | `0, 0, 0` | 0 to 1 |  |  |
| `postage_stamp_frame` | Static Frame | int | `1` | -2147483648 to 2147483647 |  |  |
| `lifetimeStart` | Lifetime Start | int | `0` | -2147483648 to 2147483647 |  |  |
| `lifetimeEnd` | Lifetime End | int | `100` | -2147483648 to 2147483647 |  |  |
| `useLifetime` | Use Lifetime | boolean | `false` |  |  |  |
| `cached` | Cached | boolean | `false` |  |  |  |
| `bookmark` | Bookmark | boolean | `false` |  |  |  |
| `dope_sheet` | Dope Sheet | boolean | `false` |  |  |  |
| `clone_group` | Clone Group | string |  |  |  |  |
| `link_source` | Link Source | string |  |  |  |  |
| `link_overrides` | Link Overrides | string |  |  |  |  |
| `split_views` | Split Views | string |  |  |  |  |

## Examples

Open these from **Help › Examples…**, or from the **?** menu in this node's Properties panel.

- **Bright values, NaN and inf** (`examples/io/read_hdr_nan_inf.oink`): TestImages/BrightRingsNanInf.exr has rings brighter than 1000 and a few NaN / inf pixels in the middle. Oink never clamps in the pipeline, so they reach the Viewer as they are. The Clamp limits the rings to 0-1; the NaN pixels stay NaN (look at them with the Viewer's pixel readout), which is why you fix NaNs at the source before a blur spreads them.


---
Sources: opencomp_core/nodes/color/clamp.py, opencomp_electron/src/components/properties/knobSchema.ts, opencomp_core/nk/mapping.py
