PsdImage and
Layer, giving .NET 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 .NET is MIT licensed. Install it with
git clone https://github.com/aspose-psd-foss/Aspose.PSD-FOSS-for-.NET.git — the library has zero third-party native
dependencies, only the .NET BCL. For the enterprise product family, see Aspose.PSD — Enterprise Product Family.Image.Load(filePath) or Image.Load(stream) opens a file and returns an Image, cast to PsdImage for PSD-specific accessPsdImage.Width, Height, and Size report the canvas dimensionsPsdImage.ColorMode (ColorModes), BitsPerChannel, and Compression (CompressionMethod) describe how the pixel data is encodedPsdImage.Version (PsdVersion) distinguishes standard PSD from the large-document PSB variantPsdImage.Layers returns every Layer in document order; PsdImage.ActiveLayer reports which one is activeLayer exposes Name, Bounds, Opacity, IsVisible, and BlendModeKey (BlendMode)Layer.ChannelInformation and Layer.LayerMaskData expose channel and mask metadata for deeper inspectionLayer.ChannelsCount reports how many image channels a layer carriesLayer.Name, Layer.Left/Top/Right/Bottom, and Layer.BlendModeKey can be set directlyPsdImage.Save(filePath) or PsdImage.Save(stream) persists the modified document back to diskImage.Load confirms the edits round-trip correctlyNotSupportedException if set — this build supports metadata-only edits, not full re-authoringPsdImage.ImageResources and GlobalLayerResources expose ResourceBlock/LayerResource collectionsPsdImage.GlobalLayerMaskInfo reports document-wide layer mask infoPsdImage.IsFlatten and HasTransparencyData report document-level flagsPsdLoadException and PsdSaveException surface load/save errors with clear messagesLoad a file with Image.Load and cast the result to PsdImage for PSD-specific members.
using var image = (PsdImage)Image.Load("test.psd");
Console.WriteLine($"Width: {image.Width}, Channels: {image.ChannelsCount}, Layers: {image.Layers.Length}");
Layer layer = image.Layers[0];
Console.WriteLine($"Bounds: {layer.Bounds}, BlendMode: {layer.BlendModeKey}, Opacity: {layer.Opacity}, Visible: {layer.IsVisible}");
Layer name, bounds, and blend mode can be changed in place and saved back to disk.
using (var image = (PsdImage)Image.Load("test.psd"))
{
image.Layers[0].Name = "Renamed layer";
image.Layers[0].Left = 10;
image.Layers[0].Top = 20;
image.Layers[0].Right = 40;
image.Layers[0].Bottom = 60;
image.Layers[0].BlendModeKey = BlendMode.Multiply;
image.Save("edited.psd");
}
using var reloaded = (PsdImage)Image.Load("edited.psd");
Console.WriteLine($"Name: {reloaded.Layers[0].Name}, BlendMode: {reloaded.Layers[0].BlendModeKey}");
Channel information can be read but not reassigned — attempting to set it throws NotSupportedException.
using var image = (PsdImage)Image.Load("test.psd");
Layer layer = image.Layers[0];
ChannelInformation[] channelInformation = layer.ChannelInformation;
Console.WriteLine($"Channel count: {layer.ChannelsCount}, First channel length: {channelInformation[0].Length}");
// layer.ChannelInformation = channelInformation; // throws NotSupportedException
Aspose.PSD FOSS for .NET 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 throw NotSupportedException if set.