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

# Positioning & Sizing | Remove Video Background Positioning

> Master video layer positioning with 9 anchor points, pixel-perfect offsets, and multiple sizing modes. Create professional multi-layer compositions.

## Positioning System

Position your video layers using anchors and offsets for pixel-perfect control:

> [card] ⚓ Anchors
>
> **9 anchor points** for easy positioning

> [card] 📏 Offsets
>
> **Pixel offsets** for fine-tuning position

> [card] 📐 Size Modes
>
> **Multiple sizing options** for different needs

## Anchor Points

Use anchor points to position layers relative to the canvas:

| TOP\_LEFT | TOP\_CENTER | TOP\_RIGHT |
| :-: | :-: | :-: |
| CENTER\_LEFT | CENTER | CENTER\_RIGHT |
| BOTTOM\_LEFT | BOTTOM\_CENTER | BOTTOM\_RIGHT |

```typescript Node.js theme={"dark"}
import { Anchor } from '@videobgremover/sdk'

// Basic positioning
comp.add(transparent).at(Anchor.CENTER)
comp.add(transparent).at(Anchor.TOP_LEFT)
comp.add(transparent).at(Anchor.BOTTOM_RIGHT)

// With pixel offsets
comp.add(transparent).at(Anchor.CENTER, 100, 50) // 100px right, 50px down
comp.add(transparent).at(Anchor.TOP_RIGHT, -20, 20) // 20px from edges
```

```python Python theme={"dark"}
from videobgremover import Anchor

# Basic positioning
comp.add(transparent).at(Anchor.CENTER)
comp.add(transparent).at(Anchor.TOP_LEFT)
comp.add(transparent).at(Anchor.BOTTOM_RIGHT)

# With pixel offsets
comp.add(transparent).at(Anchor.CENTER, dx=100, dy=50)  # 100px right, 50px down
comp.add(transparent).at(Anchor.TOP_RIGHT, dx=-20, dy=20)  # 20px from edges
```

## Size Modes

Choose how your videos are sized within the composition:

### CONTAIN (Fit Within Canvas)

Scales video to fit within canvas while preserving aspect ratio:

```typescript Node.js theme={"dark"}
import { SizeMode } from '@videobgremover/sdk'

// Fit transparent video within canvas (letterbox/pillarbox if needed)
comp.add(transparent).size(SizeMode.CONTAIN)
```

```python Python theme={"dark"}
from videobgremover import SizeMode

# Fit transparent video within canvas (letterbox/pillarbox if needed)
comp.add(transparent).size(SizeMode.CONTAIN)
```

### COVER (Fill Canvas)

Scales video to fill entire canvas, may crop edges:

```typescript Node.js theme={"dark"}
// Fill entire canvas (crop if needed)
comp.add(transparent).size(SizeMode.COVER)
```

```python Python theme={"dark"}
# Fill entire canvas (crop if needed)
comp.add(transparent).size(SizeMode.COVER)
```

### PX (Exact Pixels)

Set exact pixel dimensions:

```typescript Node.js theme={"dark"}
// Exact pixel dimensions
comp.add(transparent).size(SizeMode.PX, { width: 800, height: 600 })
```

```python Python theme={"dark"}
# Exact pixel dimensions
comp.add(transparent).size(SizeMode.PX, width=800, height=600)
```

### CANVAS\_PERCENT (Percentage of Canvas)

Size relative to canvas dimensions:

```typescript Node.js theme={"dark"}
// Square percentage (50% of both width and height)
comp.add(transparent).size(SizeMode.CANVAS_PERCENT, { percent: 50 })

// Separate width/height percentages
comp.add(transparent).size(SizeMode.CANVAS_PERCENT, { width: 75, height: 25 })

// Width only (height maintains aspect ratio)
comp.add(transparent).size(SizeMode.CANVAS_PERCENT, { width: 60 })

// Height only (width maintains aspect ratio)
comp.add(transparent).size(SizeMode.CANVAS_PERCENT, { height: 40 })
```

```python Python theme={"dark"}
# Square percentage (50% of both width and height)
comp.add(transparent).size(SizeMode.CANVAS_PERCENT, percent=50)

# Separate width/height percentages
comp.add(transparent).size(SizeMode.CANVAS_PERCENT, width=75, height=25)

# Width only (height maintains aspect ratio)
comp.add(transparent).size(SizeMode.CANVAS_PERCENT, width=60)

# Height only (width maintains aspect ratio)
comp.add(transparent).size(SizeMode.CANVAS_PERCENT, height=40)
```

### SCALE (Relative to Original)

Scale relative to the video's original dimensions:

```typescript Node.js theme={"dark"}
// Uniform scaling (150% of original size)
comp.add(transparent).size(SizeMode.SCALE, { scale: 1.5 })

// Non-uniform scaling (200% width, 80% height)
comp.add(transparent).size(SizeMode.SCALE, { width: 2.0, height: 0.8 })

// Width-only scaling (maintains aspect ratio)
comp.add(transparent).size(SizeMode.SCALE, { width: 1.2 })

// Height-only scaling (maintains aspect ratio)
comp.add(transparent).size(SizeMode.SCALE, { height: 0.7 })
```

```python Python theme={"dark"}
# Uniform scaling (150% of original size)
comp.add(transparent).size(SizeMode.SCALE, scale=1.5)

# Non-uniform scaling (200% width, 80% height)
comp.add(transparent).size(SizeMode.SCALE, width=2.0, height=0.8)

# Width-only scaling (maintains aspect ratio)
comp.add(transparent).size(SizeMode.SCALE, width=1.2)

# Height-only scaling (maintains aspect ratio)
comp.add(transparent).size(SizeMode.SCALE, height=0.7)
```

### FIT\_WIDTH / FIT\_HEIGHT

Scale to match specific canvas dimension:

```typescript Node.js theme={"dark"}
// Scale to match canvas width (height adjusts to maintain aspect ratio)
comp.add(transparent).size(SizeMode.FIT_WIDTH)

// Scale to match canvas height (width adjusts to maintain aspect ratio)
comp.add(transparent).size(SizeMode.FIT_HEIGHT)
```

```python Python theme={"dark"}
# Scale to match canvas width (height adjusts to maintain aspect ratio)
comp.add(transparent).size(SizeMode.FIT_WIDTH)

# Scale to match canvas height (width adjusts to maintain aspect ratio)
comp.add(transparent).size(SizeMode.FIT_HEIGHT)
```

## Visual Effects

### Opacity

Control layer transparency:

```typescript Node.js theme={"dark"}
comp.add(transparent).opacity(0.7) // 70% opacity
comp.add(transparent).opacity(0.3)      // 30% opacity
comp.add(transparent).opacity(0.0)   // Invisible
```

```python Python theme={"dark"}
comp.add(transparent).opacity(0.7)  # 70% opacity
comp.add(transparent).opacity(0.3)       # 30% opacity
comp.add(transparent).opacity(0.0)    # Invisible
```

## Size Mode Comparison

| Mode | Use Case | Aspect Ratio | Example |
| - | - | - | - |
| **CONTAIN** | Fit entire video | Preserved | Video player |
| **COVER** | Fill canvas | Preserved (may crop) | Background video |
| **PX** | Exact dimensions | May stretch | Fixed overlays |
| **CANVAS\_PERCENT** | Responsive sizing | Preserved | Picture-in-picture |
| **SCALE** | Relative to original | Configurable | Zoom effects |
| **FIT\_WIDTH** | Match canvas width | Preserved | Full-width banner |
| **FIT\_HEIGHT** | Match canvas height | Preserved | Sidebar video |

## Practical Examples

### Picture-in-Picture

Classic PIP layout with main video and small overlay:

```typescript Node.js theme={"dark"}
// Main video (full screen)
comp.add(mainVideo, 'main')
  .at(Anchor.CENTER)
  .size(SizeMode.CONTAIN)

// PIP video (small, top-right corner)
comp.add(pipVideo, 'pip')
  .at(Anchor.TOP_RIGHT, -30, 30)
  .size(SizeMode.CANVAS_PERCENT, { percent: 25 })
  .opacity(0.9)
```

```python Python theme={"dark"}
# Main video (full screen)
comp.add(main_video, 'main') \
    .at(Anchor.CENTER) \
    .size(SizeMode.CONTAIN)

# PIP video (small, top-right corner)
comp.add(pip_video, 'pip') \
    .at(Anchor.TOP_RIGHT, dx=-30, dy=30) \
    .size(SizeMode.CANVAS_PERCENT, percent=25) \
    .opacity(0.9)
```

### Side-by-Side Comparison

Two videos side by side:

```typescript Node.js theme={"dark"}
// Left transparent video
comp.add(transparent1)
  .at(Anchor.CENTER_LEFT, 50)
  .size(SizeMode.CANVAS_PERCENT, { width: 45 })

// Right transparent video
comp.add(transparent2)
  .at(Anchor.CENTER_RIGHT, -50)
  .size(SizeMode.CANVAS_PERCENT, { width: 45 })
```

```python Python theme={"dark"}
# Left transparent video
comp.add(transparent1) \
    .at(Anchor.CENTER_LEFT, dx=50) \
    .size(SizeMode.CANVAS_PERCENT, width=45)

# Right transparent video
comp.add(transparent2) \
    .at(Anchor.CENTER_RIGHT, dx=-50) \
    .size(SizeMode.CANVAS_PERCENT, width=45)
```

### Overlay Grid

Multiple small overlays in a grid:

```typescript Node.js theme={"dark"}
const gridSize = 20 // 20% of canvas for each video
const margin = 30   // 30px margin from edges

// 2x2 grid
comp.add(transparent1).at(Anchor.TOP_LEFT, margin, margin)
    .size(SizeMode.CANVAS_PERCENT, { percent: gridSize })
comp.add(transparent2).at(Anchor.TOP_RIGHT, -margin, margin)
    .size(SizeMode.CANVAS_PERCENT, { percent: gridSize })
comp.add(transparent3).at(Anchor.BOTTOM_LEFT, margin, -margin)
    .size(SizeMode.CANVAS_PERCENT, { percent: gridSize })
comp.add(transparent4).at(Anchor.BOTTOM_RIGHT, -margin, -margin)
    .size(SizeMode.CANVAS_PERCENT, { percent: gridSize })
```

```python Python theme={"dark"}
grid_size = 20  # 20% of canvas for each transparent video
margin = 30     # 30px margin from edges

# 2x2 grid
comp.add(transparent1).at(Anchor.TOP_LEFT, dx=margin, dy=margin) \
    .size(SizeMode.CANVAS_PERCENT, percent=grid_size)
comp.add(transparent2).at(Anchor.TOP_RIGHT, dx=-margin, dy=margin) \
    .size(SizeMode.CANVAS_PERCENT, percent=grid_size)
comp.add(transparent3).at(Anchor.BOTTOM_LEFT, dx=margin, dy=-margin) \
    .size(SizeMode.CANVAS_PERCENT, percent=grid_size)
comp.add(transparent4).at(Anchor.BOTTOM_RIGHT, dx=-margin, dy=-margin) \
    .size(SizeMode.CANVAS_PERCENT, percent=grid_size)
```

## Z-Order (Layer Stacking)

Control which layers appear in front:

```typescript Node.js theme={"dark"}
// Background layer (behind everything)
comp.add(backgroundVideo, 'bg').z(0)

// Main content (middle layer)
comp.add(mainVideo, 'main').z(10)

// Overlay effects (in front)
comp.add(overlayVideo, 'overlay').z(20)

// Logo (always on top)
comp.add(logoVideo, 'logo').z(100)
```

```python Python theme={"dark"}
# Background layer (behind everything)
comp.add(background_video, 'bg').z(0)

# Main content (middle layer)
comp.add(main_video, 'main').z(10)

# Overlay effects (in front)
comp.add(overlay_video, 'overlay').z(20)

# Logo (always on top)
comp.add(logo_video, 'logo').z(100)
```

## Alpha Channel Control

Control transparency processing for each layer:

```typescript Node.js theme={"dark"}
// Use alpha channel (default - transparent background shows through)
comp.add(transparent).alpha(true)

// Ignore alpha channel (opaque - background becomes black)
comp.add(transparent).alpha(false)
```

```python Python theme={"dark"}
# Use alpha channel (default - transparent background shows through)
comp.add(transparent).alpha(enabled=True)

# Ignore alpha channel (opaque - background becomes black)
comp.add(transparent).alpha(enabled=False)
```

## Tips & Best Practices

### Responsive Design

Use percentage-based sizing for responsive layouts:

```typescript theme={"dark"}
// Main content takes 70% width, sidebar takes 25%
comp.add(mainVideo, 'main').size(SizeMode.CANVAS_PERCENT, { width: 70 })
comp.add(sideVideo, 'side').size(SizeMode.CANVAS_PERCENT, { width: 25 })
```

### Visual Hierarchy

* Use z-order to control layer stacking
* Use opacity to create depth
* Use size to emphasize importance

## What's Next?

> [card] [⏰ Control Timing](https://docs.videobgremover.com/video-composition/timing.md)
>
> Learn how to control when layers appear and disappear

> [card] [🎬 Export Your Video](https://docs.videobgremover.com/video-composition/export-formats.md)
>
> Choose the right export format and quality settings


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