Introduction
Aspose.PSD FOSS for Python is a new open-source library for working with PSD and PSB (Photoshop large document) files from Python code. It is released under the MIT license, has zero third-party native dependencies, and requires only the Python standard library at runtime. The package is imported as aspose_psd_foss.
The library is organized around the PsdImage class, which extends the abstract Image base class, and the Layer class. Image.load() / PsdImage.load() load a document from a file path or a stream, exposing header information (width, height, color_mode, version, compression) and the parsed layers collection; PsdImage.save() writes the document back out to a file or stream. Both classes support the with statement for automatic cleanup. Each Layer exposes its own metadata — name, bounds, is_visible, opacity, clipping, blend_mode_key, and channel/mask information — and a subset of these properties can be changed in place and saved back to the file.
This release is for developers who need to inspect or make limited metadata edits to PSD/PSB files inside a Python codebase without a commercial license — asset-pipeline tooling that reports on layer structure, build scripts that rename or toggle layer visibility before handoff, or test fixtures that need to read PSD header and layer data without a full rendering engine. The library does not render pixel data or convert PSD/PSB to other image formats — it is a metadata-focused reader/writer for the PSD/PSB container format.
What’s Included
Document Inspection
PsdImage.load() parses a PSD or PSB file’s header into typed properties — width, height, bits_per_channel, color_mode, version, compression, size, and is_flatten — without decoding pixel data.
from aspose_psd_foss.psdimage import PsdImage
with PsdImage.load("input.psd") as image:
print(f"Width: {image.width}, Height: {image.height}")
print(f"ColorMode: {image.color_mode}, Version: {image.version}")
print(f"Layers: {image.layer_count}, Compression: {image.compression}")
Layer Metadata
Each entry in PsdImage.layers is a Layer exposing its own bounds, visibility, opacity, clipping, and blend-mode metadata.
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}, Visible={layer.is_visible}, Opacity={layer.opacity}")
Supported Metadata Edits
A subset of layer properties can be changed in place and written back with PsdImage.save(): name, visibility, opacity, clipping, blend mode key, and the four bounds edges.
from aspose_psd_foss.psdimage import PsdImage
from aspose_psd_foss.layers.blendmode import BlendMode
with PsdImage.load("input.psd") as image:
layer = image.layers[0]
layer.name = f"{layer.name} (edited)"
layer.is_visible = not layer.is_visible
layer.opacity = 128
layer.blend_mode_key = BlendMode.MULTIPLY
image.save("output.psd")
Quick Start
Install the package, then load a PSD or PSB file, inspect its layers, and save it back out:
git clone https://github.com/aspose-psd-foss/Aspose.PSD-FOSS-for-Python.git
cd Aspose.PSD-FOSS-for-Python
# No packaging manifest is published yet -- run from this folder,
# or add it to PYTHONPATH:
export PYTHONPATH=$PWD:$PYTHONPATHfrom aspose_psd_foss.psdimage import PsdImage
with PsdImage.load("input.psd") as image:
print(f"Width: {image.width}, Height: {image.height}, Layers: {image.layer_count}")
for layer in image.layers:
print(f" {layer.name}: {layer.bounds}")
image.save("output.psd")
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.