---
Product: psd
Platform: net
Page Type: kb
Canonical URL: https://kb.aspose.org/psd/net/how-to-work-with-layers-dotnet
Last Updated: 2026-10-08
---

# How to Work with PSD Layers in .NET

Read and edit layer metadata — name, visibility, opacity, clipping, and blend mode — using the Layer class in Aspose.PSD FOSS for .NET.

This guide shows how to list a document's layers, read and change editable
layer metadata, reposition a layer, and remove a layer from the collection.
A loaded `PsdImage`'s `Layers` property returns its collection of `Layer`
objects. Each `Layer` exposes editable metadata — name, visibility, opacity,
clipping, blend mode, and position (bounds edges) — plus read-only overall
bounds and channel information.

## Step-by-Step Guide

### Step 1: Install the Package

```bash
dotnet add package Aspose.PSD.FOSS
```

---

### Step 2: Import Required Classes

The LINQ extension methods used later (`Where`) come from `System.Linq`;
the PSD-specific types come from the two Aspose.PSD namespaces below.

```csharp
using System.Linq;
using Aspose.PSD.FileFormats.Psd;
using Aspose.PSD.FileFormats.Core.Blending;
```

---

### Step 3: Load a Document and List Its Layers

Load the document, then iterate `Layers` to see each layer's name and
geometry:

```csharp
using var image = PsdImage.Load("input.psd");

foreach (var layer in image.Layers)
{
    Console.WriteLine($"{layer.Name}: {layer.Width}x{layer.Height} at ({layer.Left},{layer.Top})");
}
```

---

### Step 4: Read and Edit Layer Visibility, Opacity, and Blend Mode

`IsVisible`, `Opacity` (0-255), `Clipping`, `Name`, and `BlendModeKey` all
have working setters:

```csharp
var layer = image.Layers[0];

layer.IsVisible = false;          // hide the layer
layer.Opacity = 200;              // ~78% opacity
layer.BlendModeKey = BlendMode.Multiply;
layer.Name = "Renamed Layer";
```

---

### Step 5: Read and Reposition Layer Bounds

`Bounds`, `Width`, `Height`, and `ChannelsCount` are read-only — but `Top`,
`Left`, `Bottom`, and `Right` each have a working setter that repositions
the layer:

```csharp
Console.WriteLine($"Bounds: {layer.Bounds}");
Console.WriteLine($"Channels: {layer.ChannelsCount}");

layer.Left = 10;
layer.Top = 20;
layer.Right = 40;
layer.Bottom = 60;
```

---

### Step 6: Replace the Layers Collection

`PsdImage.Layers` itself has a working setter, so you can replace the whole
collection (for example, to remove a layer):

```csharp
image.Layers = image.Layers.Where(l => l.Name != "Renamed Layer").ToArray();
```

---

### Step 7: Save the Document

Persist every edit made in the previous steps back to disk:

```csharp
image.Save("output.psd");
```

## Common Issues and Fixes

**`NotSupportedException` when setting `ChannelInformation`, `LayerMaskData`,
or `LayerBlendingRangesData`.** These three `Layer` setters are not supported
in this FOSS build — treat them as read-only.

**Opacity value looks wrong after setting it.** `Opacity` is a `byte`
(0-255), not a 0.0-1.0 fraction or a percentage — `layer.Opacity = 200`
means roughly 78% opaque (200/255).

**Changes to a layer don't appear after saving.** Confirm you are modifying
the `Layer` instance obtained from `image.Layers`, and that you call
`image.Save` after making your edits.

## Frequently Asked Questions

### Can I remove a layer from a document?

Yes — `PsdImage.Layers` has a working setter, so you can assign it a filtered
array to remove layers (see Step 6).

### What blend modes are available?

`BlendMode` includes values such as `Normal`, `Multiply`, `Screen`,
`Overlay`, and `Darken`, among others — set via `Layer.BlendModeKey`.

### Is layer mask data available?

`Layer.LayerMaskData` has a working getter, but its setter throws
`NotSupportedException` in this FOSS build.

## See Also

- [Working with the Core API](../how-to-work-with-psd-core-api-dotnet/)
- [Aspose.PSD FOSS for .NET — Frequently Asked Questions](../faq/)
- [Aspose.PSD FOSS for .NET developer guide](https://docs.aspose.org/psd/net/developer-guide/)
- [Aspose.PSD for .NET — Enterprise Knowledge Base](https://kb.aspose.com/psd/net/)