---
Product: psd
Platform: net
Page Type: kb
Canonical URL: https://kb.aspose.org/psd/net/how-to-work-with-psd-core-api-dotnet
Last Updated: 2026-10-08
---

# How to Work with the Aspose.PSD FOSS Core API in .NET

Load a PSD/PSB document, inspect its header and image resources, and save it back to disk using PsdImage, Image, ColorModes, CompressionMethod, and ResourceBlock in Aspose.PSD FOSS for .NET.

Aspose.PSD FOSS for .NET loads and inspects PSD/PSB document structure through
`PsdImage`, a subclass of `Image`. This article covers loading a document,
reading its header and image resources, and saving it back to disk.

## Step-by-Step Guide

### Step 1: Install the Package

```bash
dotnet add package Aspose.PSD.FOSS
```

---

### Step 2: Import Required Classes

```csharp
using Aspose.PSD.FileFormats.Psd;
```

---

### Step 3: Load a PSD/PSB Document

`PsdImage.Load` opens a document from a file path or a stream:

```csharp
using var image = PsdImage.Load("input.psd");
```

---

### Step 4: Inspect the Document Header

`PsdImage` exposes header fields read from the parsed document: `Width`,
`Height`, `BitsPerChannel`, `ColorMode` (a `ColorModes` value), and
`Compression` (a `CompressionMethod` value):

```csharp
Console.WriteLine($"{image.Width}x{image.Height}, {image.BitsPerChannel} bpc");
Console.WriteLine($"Color mode: {image.ColorMode}");   // e.g. ColorModes.Rgb
Console.WriteLine($"Compression: {image.Compression}"); // e.g. CompressionMethod.RLE
Console.WriteLine($"Flattened: {image.IsFlatten}");
```

`ColorModes` values include `Bitmap`, `Grayscale`, `Indexed`, `Rgb`, and
`Cmyk`, among others (`Multichannel`, `Duotone`, `Lab`).
`CompressionMethod` values are `Raw`, `RLE`, `ZipWithoutPrediction`, and a
ZIP-with-prediction variant.

---

### Step 5: Read Image Resource Blocks

`ImageResources` returns the document's parsed `ResourceBlock` entries. Each
block exposes `ID`, `Name`, and `Size`:

```csharp
foreach (var resource in image.ImageResources)
{
    Console.WriteLine($"Resource {resource.ID} \"{resource.Name}\" - {resource.Size} bytes");
}
```

`ImageResources` is read-only in this FOSS build — assigning to it throws
`NotSupportedException` (see Known Limitations in the
[FAQ](../faq/)).

---

### Step 6: Save the Document

```csharp
image.Save("output.psd");
```

## Common Issues and Fixes

**`PsdLoadException` when loading a file.** The input is not a valid PSD/PSB
document, or its header failed validation. Confirm the file is a genuine
PSD/PSB file before loading.

**`NotSupportedException` when setting `ImageResources` or
`GlobalLayerResources`.** These setters are not supported in this FOSS build.
Treat `ImageResources` as read-only.

**`ColorMode` or `Compression` prints as a numeric value instead of a name.**
Cast the property to its enum type explicitly, or use `.ToString()`, to get
the readable name (`ColorModes.Rgb`, not `3`).

## Frequently Asked Questions

### Can I load a PSD file from a stream instead of a file path?

Yes — `PsdImage.Load` has an overload that accepts a `Stream`.

### Does `ImageResources` include layer data?

No. `ImageResources` holds document-level resource blocks (parsed from the
PSD image resources section). Layer-level data is read through
`PsdImage.Layers` — see [Working with Layers](../how-to-work-with-layers-dotnet/).

### Is `PsdImage.Version` the PSD file format version?

No. `PsdImage.Version` reports an internal Aspose.PSD-compatible API version
number (currently `6`) — it is unrelated to whether the loaded file is PSD
or PSB.

## See Also

- [Working with Layers](../how-to-work-with-layers-dotnet/)
- [Aspose.PSD FOSS for .NET — Frequently Asked Questions](../faq/)
- [Aspose.PSD FOSS for .NET developer guide](https://docs.aspose.org/psd/net/developer-guide/)
- [Aspose.PSD for .NET — Enterprise Knowledge Base](https://kb.aspose.com/psd/net/)