PsdImage and
Layer, giving Python developers programmatic access to a PSD document’s structure with no
native dependencies to compile. The library reads a PSD/PSB file’s dimensions, color mode, bit depth, and compression
method, and exposes every layer through PsdImage.layers: each Layer reports its name,
bounds, opacity, visibility, and blend mode key (BlendMode), along with lower-level
channel information (ChannelInformation) and mask data (LayerMaskData). A subset of
layer metadata — name, bounds (left/top/right/bottom), and blend mode — can be
modified in place and persisted back to disk with PsdImage.save(); everything else on the
surface is read-only by design in this FOSS build. Aspose.PSD FOSS for Python is MIT licensed. Install it with
git clone https://github.com/aspose-psd-foss/Aspose.PSD-FOSS-for-Python.git — the library has zero third-party native
dependencies, only the Python standard library. For the enterprise product family, see Aspose.PSD — Enterprise Product Family.Image.load(file_path) opens a file and returns a PsdImage instancePsdImage.width, height, and channels_count report the canvas dimensions and channel countPsdImage.layers returns the full list of Layer objects in document orderPsdImage.layers returns every Layer in document order; each Layer exposes name, bounds, opacity, is_visible, and blend_mode_keyLayer.channel_information exposes channel metadata for deeper inspectionLayer.channels_count reports how many image channels a layer carriesPsdImage.layers itself can be reassigned to remove or reorder layersLayer.name, Layer.left/top/right/bottom, and Layer.blend_mode_key can be set directlyPsdImage.save(file_path) persists the modified document back to diskPsdImage.load confirms the edits round-trip correctlyNotSupportedException if set — this build supports metadata-only edits, not full re-authoringLayer.channel_information exposes per-channel metadata collectionsLayer.has_mask_data and has_blending_ranges_data report whether optional sections are presentPsdLoadException and PsdSaveException surface load/save errors with clear messagesLoad a file with Image.load to get a PsdImage instance for PSD-specific members.
from aspose_psd_foss.image import Image
with Image.load("test.psd") as image:
print(f"Width: {image.width}, Channels: {image.channels_count}, Layers: {len(image.layers)}")
Layer bounds and blend mode can be changed in place and saved back to disk.
from aspose_psd_foss.psdimage import PsdImage
from aspose_psd_foss.layers.blendmode import BlendMode
with PsdImage.load("test.psd") as image:
image.layers[0].left = 10
image.layers[0].top = 20
image.layers[0].right = 40
image.layers[0].bottom = 60
image.layers[0].blend_mode_key = BlendMode.MULTIPLY
image.save("edited.psd")
with PsdImage.load("edited.psd") as reloaded:
print(f"Bounds: {reloaded.layers[0].bounds}, BlendMode: {reloaded.layers[0].blend_mode_key}")
Channel information can be read but not reassigned — attempting to set it raises NotSupportedException.
from aspose_psd_foss.psdimage import PsdImage
with PsdImage.load("test.psd") as image:
layer = image.layers[0]
channel_information = layer.channel_information
print(f"Channel count: {layer.channels_count}, first channel: {channel_information[0]}")
# layer.channel_information = channel_information # raises NotSupportedException
Aspose.PSD FOSS for Python is MIT licensed. You can use, modify, and redistribute it under the terms of the MIT license, including in commercial products.
See the install section above for the current install command.
It loads and saves PSD and PSB (Photoshop large document) files. It does not render or export pixel data to other raster formats such as PNG or JPEG.
PsdImage (a subclass of Image). Load a document with PsdImage.load, then read its layers collection and header properties.
Yes — Layer exposes a working setter for several properties, such as visibility and name, and PsdImage.layers itself has a working setter for replacing the collection. A few specific properties (channel information, mask data, blending ranges, and some document- level resources) are read-only in this FOSS build and raise NotSupportedException if set.