---
Product: psd
Platform: python
Page Type: docs
Canonical URL: https://docs.aspose.org/psd/python/developer-guide/core-api
---

# Core API

An overview of the PsdImage/Image class hierarchy for loading, inspecting, and saving PSD/PSB documents, and the document-level properties and resources it exposes.

## Overview

`PsdImage` is the entry point for loading, inspecting, and saving PSD/PSB documents. It extends the abstract `Image` base class, which declares only `load()` — the rest of the document surface (`width`, `height`, `save()`, context-manager support) is defined on `PsdImage` itself, not inherited.

---

### Loading and Saving Documents

`Image.load()` accepts a file path or a stream and returns an `Image`; for PSD/PSB input this is always a `PsdImage`, so the document surface is immediately available without an explicit cast. `PsdImage` also supports the `with` statement for automatic cleanup, and `PsdImage.save()` writes the document back out to a file path or stream.

```python
from aspose_psd_foss.psdimage import PsdImage

with PsdImage.load(input_path) as image:
    # ... inspect or edit ...
    image.save(output_path)
```

---

### Document Header Properties

`PsdImage` exposes the parsed header as typed properties: `width`, `height`, `bits_per_channel`, `color_mode`, `version`, `compression`, `size`, and `is_flatten`.

```python
print(f"Width: {image.width}, Height: {image.height}")
print(f"ColorMode: {image.color_mode}, Version: {image.version}")
print(f"Compression: {image.compression}, IsFlatten: {image.is_flatten}")
```

---

### Image Resources

`PsdImage.image_resources` returns the parsed list of `ResourceBlock` objects. In this FOSS build, `image_resources`, `global_layer_resources`, `active_layer`, and `has_transparency_data` can be read but not reassigned — their setters raise `NotSupportedException`.

```python
for resource in image.image_resources:
    print(f"Resource {resource.id}: {resource.name} ({resource.data_size} bytes)")
```

---

### Tips and Best Practices

- `Image.load()` already returns a `PsdImage` for PSD/PSB input — no cast is needed, unlike some other language ports of this library.
- Use the `with` statement; `PsdImage` supports the context-manager protocol for cleanup.
- Treat `image_resources`, `global_layer_resources`, `active_layer`, and `has_transparency_data` as read-only even though they expose a setter.
- Check `image.layer_count` before indexing into `image.layers` — a flattened document may have zero layers.

---

### Common Issues

| Issue | Cause | Fix |
|---|---|---|
| `NotSupportedException` when setting `image_resources` | This property is read-only in the FOSS build despite having a setter | Read the value; do not attempt to reassign it |
| Empty `image.layers` list on a flattened document | `is_flatten` is `True` and the document has no parsed layers | Check `image.layer_count` (or `image.is_flatten`) before indexing into `image.layers` |

---

### FAQ

#### Does loading a PSD document decode pixel data?

No. `PsdImage.load()` parses the document header, layer metadata, and resources without decoding or rendering pixel data.

#### Can I convert a PSD file to another image format?

No. This library loads, inspects, and saves PSD/PSB documents only — it does not render pixel data or convert to other image formats.

---

### API Reference Summary

| Class/Method | Description |
|---|---|
| `Image.load(path)` / `Image.load(stream)` | Loads a PSD or PSB document |
| `PsdImage.save(path)` / `PsdImage.save(stream)` | Saves the document |
| `PsdImage.width` / `height` / `bits_per_channel` / `color_mode` / `version` / `compression` / `size` / `is_flatten` | Document header properties |
| `PsdImage.image_resources` | Parsed image resource blocks (read-only) |

## See Also

- [Aspose.PSD — Enterprise Documentation](https://docs.aspose.com/psd/)