Table of Contents

Class PsdLayer

Namespace
Egami.Formats.Psd
Assembly
Egami.dll

One layer record of a PSD file, read as metadata: the layer's pixels are not loaded.

public sealed record PsdLayer : IEquatable<PsdLayer>
Inheritance
PsdLayer
Implements
Inherited Members

Examples

// Layer records come as metadata, bottom to top as the file lists them; their pixels are not loaded.
using Raster image = Raster.Load("layered.psd");
foreach (PsdLayer layer in ((PsdDetails)image.Metadata.FormatDetails!).Layers)
{
    if (layer.Kind == PsdLayerKind.GroupEnd)
    {
        continue;
    }

    string kind = layer.Kind == PsdLayerKind.Layer ? "layer" : "group";
    Console.WriteLine($"{new string(' ', 2 * layer.Level)}{layer.Name} ({kind}, {layer.BlendModeKey}, opacity {layer.Opacity:P0}{(layer.IsVisible ? "" : ", hidden")})");
}

Constructors

PsdLayer(string, Rect, float, string, BlendMode?, bool, bool, PsdLayerKind, int)

One layer record of a PSD file, read as metadata: the layer's pixels are not loaded.

public PsdLayer(string Name, Rect Bounds, float Opacity, string BlendModeKey, BlendMode? BlendMode, bool IsVisible, bool IsClipped, PsdLayerKind Kind, int Level)

Parameters

Name string

The layer's name: its Unicode name when the file has one, else its Pascal name.

Bounds Rect

Where the layer's pixels lie in the image; empty for groups and layers without pixels.

Opacity float

The opacity, 0 (transparent) to 1, as DrawImage takes it; the file stores it in 256 steps.

BlendModeKey string

The blend mode as Photoshop names it, such as "norm", "mul " or "pass" (pass through, for groups).

BlendMode BlendMode?

The same blend mode in Egami's terms, or null when Egami has none like it.

IsVisible bool

Whether the layer is shown.

IsClipped bool

Whether the layer is clipped to the layer below it (a clipping mask).

Kind PsdLayerKind

Whether the record is a layer or one end of a group.

Level int

How many groups the record is inside; a group's own records are at the level outside it.

Examples

// Layer records come as metadata, bottom to top as the file lists them; their pixels are not loaded.
using Raster image = Raster.Load("layered.psd");
foreach (PsdLayer layer in ((PsdDetails)image.Metadata.FormatDetails!).Layers)
{
    if (layer.Kind == PsdLayerKind.GroupEnd)
    {
        continue;
    }

    string kind = layer.Kind == PsdLayerKind.Layer ? "layer" : "group";
    Console.WriteLine($"{new string(' ', 2 * layer.Level)}{layer.Name} ({kind}, {layer.BlendModeKey}, opacity {layer.Opacity:P0}{(layer.IsVisible ? "" : ", hidden")})");
}

Properties

BlendMode

The same blend mode in Egami's terms, or null when Egami has none like it.

public BlendMode? BlendMode { get; init; }

Property Value

BlendMode?

BlendModeKey

The blend mode as Photoshop names it, such as "norm", "mul " or "pass" (pass through, for groups).

public string BlendModeKey { get; init; }

Property Value

string

Bounds

Where the layer's pixels lie in the image; empty for groups and layers without pixels.

public Rect Bounds { get; init; }

Property Value

Rect

FillOpacity

Gets the fill opacity, 0 to 1: like Opacity, but it leaves layer effects alone. 1 when the file names none; the file stores it in 256 steps.

public float FillOpacity { get; init; }

Property Value

float

IsClipped

Whether the layer is clipped to the layer below it (a clipping mask).

public bool IsClipped { get; init; }

Property Value

bool

IsVisible

Whether the layer is shown.

public bool IsVisible { get; init; }

Property Value

bool

Kind

Whether the record is a layer or one end of a group.

public PsdLayerKind Kind { get; init; }

Property Value

PsdLayerKind

LayerType

Gets what the layer holds: pixels, text, a shape, a smart object, a fill, an adjustment, or a group.

public PsdLayerType LayerType { get; init; }

Property Value

PsdLayerType

Level

How many groups the record is inside; a group's own records are at the level outside it.

public int Level { get; init; }

Property Value

int

Name

The layer's name: its Unicode name when the file has one, else its Pascal name.

public string Name { get; init; }

Property Value

string

Opacity

The opacity, 0 (transparent) to 1, as DrawImage takes it; the file stores it in 256 steps.

public float Opacity { get; init; }

Property Value

float