# Advanced Layer Actions

Fater provides several advanced actions you can perform on individual layers, primarily accessed through **buttons directly on each layer item** in the **Layers Tab**. These actions help with precise compositing, workflow efficiency, and specific AI preparations.

***

### 1. Applying Layer Content to the Main Mask (`Wand` icon )

* **How:**
  1. Identify the layer whose content (non-transparent pixels) you want to use to define a selection.
  2. In the **Layers Tab**, locate that specific layer item.
  3. Click the **"Apply Layer to Mask"** (Wand) icon on that layer's item.
  4. Hold **Alt** while clicking the Wand icon to *subtract* the layer's shape from the main mask instead of adding to it.
* **Action:** This operation modifies the **main mask** on the **Inpaint Canvas**.
  * **Default (Add):** All non-transparent pixels of the clicked layer are added to the main mask, effectively selecting those areas.
  * **Alt+Click (Subtract):** All non-transparent pixels of the clicked layer are removed (made transparent) from the main mask, effectively deselecting those areas.
* **Use Case:** Quickly creating a mask based on an existing object or element on a layer, useful for then targeting AI inpainting to that shape, or for further refining the mask with other tools.

***

### 2. Resizing the Generation Canvas to Fit a Layer (`Crop` icon 🖼️)

* **How:** In the Layers Tab, locate the layer item you want the canvas to fit. Click the **"Resize Canvas to Layer"** (Crop) icon on that layer's item.
* **Action:** The **Generation Area Bounding Box** on the main canvas will automatically resize and reposition to perfectly match the bounds of that specific layer's visible content.
* **Use Case:** Essential after adding a new base image to ensure the entire image is within the generation area. Also useful for focusing AI operations on a specific layer's content by making it the active generation area.

***

### 3. Zooming to a Specific Layer (`ZoomIn` icon 🔍 / Double-Click Thumbnail)

* **How:**
  * **Button:** On the layer item in the Layers Tab, a "Zoom on Layer" (ZoomIn) icon might be available.
  * **Double-Click:** **Double-click the preview thumbnail** of the layer in the Layers Tab.
* **Action:** The main **Inpaint Canvas** view will pan and zoom to fit that specific layer's content within the visible area.
* **Use Case:** Quickly navigate to and focus on a specific layer in a complex project.

***

### 4. Merging Layers Down (`Merge` icon 📥)

* **How:** In the Layers Tab, identify the layer you want to merge *down* (the upper layer). Ensure there is a visible layer directly beneath it in the same **Layer Workspace**. Click the **"Merge Down"** icon on the upper layer's item (this icon typically appears if the layer is not the bottom-most in its workspace).
* **Action:** Combines the visual content of the clicked layer and the layer directly below it into a single, new layer. The new layer replaces the bottom one of the pair, and the original top layer (the one you clicked "Merge Down" on) is removed from the stack.
* **Important Considerations for Merging:**
  * **Area Coverage:** The resulting merged layer will visually cover the **combined area (union)** of the two original layers.
  * **Resolution & Quality:** Fater attempts to preserve the maximum possible quality. However, the internal canvas for the merged layer has a **maximum side length of 16,384 pixels**.
  * **Impact of Distance:** If you merge two layers that are very far apart on a large canvas, or if their combined area would exceed this pixel limit, the merged result **might be downscaled**, potentially reducing its visual quality or sharpness compared to the originals.
  * **Destructive Operation:** Merging is a destructive action for the two original layers. Consider duplicating layers before merging if you might need the originals later.
* **Use Case:** Simplifies your layer stack by combining elements that are finalized, reducing project complexity and potentially improving performance.
