---
Product: psd
Platform: python
Page Type: index
Canonical URL: https://blog.aspose.org/psd/python/psd-layers-in-python/
Published: 2026-10-09
Author: Aspose
---

# Working with Layers in Aspose.PSD FOSS for Python

A deep dive into layer metadata in Aspose.PSD FOSS for Python: the Layer class's full property set, blend modes, layer mask flags, and the channel/mask/blending-range metadata classes used to describe a PSD layer's structure.

## Introduction

`PsdImage.layers` returns every layer in a PSD or PSB document as a list of `Layer` objects. This post looks specifically at what a `Layer` exposes: its geometry and visual state, the blend mode and mask flag enumerations, and the metadata classes that describe a layer's channels, mask, and blending ranges.

---

## What's Included

### The Layer Class

Each `Layer` carries a name (`name`), a bounding `Rectangle` (`bounds`, with derived `width`/`height`/`top`/`left`/`bottom`/`right`), visibility and compositing state (`is_visible`, `opacity`, `clipping`, `blend_mode_key`), and a channel count (`channels_count`). `name`, `is_visible`, `opacity`, `clipping`, `blend_mode_key`, and the four bounds edges can all be changed and written back with `PsdImage.save()`.

```python
from aspose_psd_foss.psdimage import PsdImage

with PsdImage.load("input.psd") as image:
    for layer in image.layers:
        print(f"{layer.name}: {layer.bounds}, "
              f"Visible={layer.is_visible}, Opacity={layer.opacity}, "
              f"BlendMode={layer.blend_mode_key}")
```

### Blend Modes and Mask Flags

`blend_mode_key` is a `BlendMode` enum value — the library defines 29 standard PSD blend modes (`NORMAL`, `MULTIPLY`, `SCREEN`, `OVERLAY`, `DARKEN`, `LIGHTEN`, `COLORDODGE`, `COLORBURN`, `HARDLIGHT`, `SOFTLIGHT`, `DIFFERENCE`, `EXCLUSION`, `HUE`, `SATURATION`, `COLOR`, `LUMINOSITY`, and others). A separate `LayerMaskFlags` flag enum (`NONE`, `RELATIVE_TO_LAYER`, `DISABLED`, `INVERTED_WHEN_BLENDING`, `USER_MASK_FROM_RENDERING_OTHER_DATA`, `USER_OR_VECTOR_MASKS_HAVE_PARAMETERS`) describes mask-rendering behavior where a layer has one.

### Channel and Mask Metadata

`Layer.channel_information` returns a list of `ChannelInformation` objects describing each channel's ID, compression method, and byte length. `Layer.layer_mask_data` (a `LayerMaskDataShort` when present) describes a layer mask's bounds and flags; `Layer.layer_blending_ranges_data` exposes the composite and per-channel blend ranges. All three of these properties are read-only in this FOSS build — their setters raise `NotSupportedException` if called, even though they appear as regular properties.

```python
from aspose_psd_foss.psdimage import PsdImage

with PsdImage.load("input.psd") as image:
    layer = image.layers[0]
    for channel in layer.channel_information:
        print(f"Channel {channel.ChannelID}: {channel.compression_method}, {channel.length} bytes")

    if layer.has_mask_data:
        mask = layer.layer_mask_data
        print(f"Mask bounds: {mask.mask_rectangle}, flags: {mask.flags}")
```

---

## Quick Start

```bash
pip install aspose-psd-foss
```

```python
from aspose_psd_foss.psdimage import PsdImage

with PsdImage.load("input.psd") as image:
    visible_layers = [layer for layer in image.layers if layer.is_visible]
    for layer in visible_layers:
        print(f"{layer.name}: Opacity={layer.opacity}, BlendMode={layer.blend_mode_key}")
```

---

## Supported Formats

| Format | Extension | Read | Write |
|---|---|---|---|
| PSD | psd | ✓ | ✓ |
| PSB | psb | ✓ | ✓ |

---

## Open Source & Licensing

Aspose.PSD FOSS for Python is MIT licensed and may be used in commercial products without royalties, with no evaluation watermark or usage limit.

The library has zero third-party native dependencies — only the Python standard library is required at runtime.

---

## Getting Started

- [Getting Started](https://docs.aspose.org/psd/python/getting-started/)
- [Developer Guide](https://docs.aspose.org/psd/python/developer-guide/)
- [KB Articles](https://kb.aspose.org/psd/python/)
- [API Reference](https://reference.aspose.org/psd/python/)

## Related Resources

- [Aspose.PSD Enterprise Product Family](https://products.aspose.com/psd/)
- [Aspose.PSD — Enterprise Blog](https://blog.aspose.com/)