---
Product: psd
Platform: python
Page Type: kb
Canonical URL: https://kb.aspose.org/psd/python/how-to-export-write-descriptors-python
Last Updated: 2026-10-08
---

# How to Save and Export PSD Documents in Python

Save a PsdImage to a file path or a writable stream using Aspose.PSD FOSS for Python, and understand which PSD/PSB container format a save produces.

This guide shows how to save an edited document to a file path, to an
open stream, and how to dispose of a loaded image afterward.
`PsdImage.save` is the single public entry point for writing a document
back out — it accepts either a file path or an already-open writable
stream. The low-level section writer that does the actual byte encoding is
an internal implementation detail, not something you call directly.

## Step-by-Step Guide

### Step 1: Install the Package

```bash
pip install aspose-psd-foss
```

---

### Step 2: Import Required Classes

`PsdImage` is the only class this guide's examples need:

```python
from aspose_psd_foss.psdimage import PsdImage
```

---

### Step 3: Save to a File Path

Load a document, make an edit, then save it back to a file path:

```python
image = PsdImage.load("input.psd")
image.layers[0].is_visible = False
image.save("output.psd")
```

---

### Step 4: Save to an Open Stream

Passing a stream instead of a path leaves the stream open after saving —
you control when to close it:

```python
with open("output.psd", "wb") as stream:
    image.save(stream)
```

---

### Step 5: Dispose the Image

Release the resources the loaded `PsdImage` holds once you're done with it:

```python
image.dispose()
```

## Common Issues and Fixes

**`RuntimeError: PsdImage has been disposed.` when calling `save`.** The
image was already disposed (via `dispose()` or a `with` block that exited)
before `save` was called. Call `save` before disposing.

**`PsdSaveException` about a Pascal string length.** A string value
exceeds 255 bytes — see
[Handling PSD Core Exceptions](../how-to-work-with-psd-core-exceptions-python/)
and [Troubleshooting](../troubleshooting/).

**No way to force a PSD or PSB container on save.** There is no public
API to choose the output container format — a save always mirrors
whichever format (`is_large_document` / `is_psb`) the document was loaded
with. If you need a different container format, there is no supported
conversion path in this FOSS build.

## Frequently Asked Questions

### Does saving to a stream close the stream afterward?

No — when you pass a stream to `save`, the stream is left open afterward
so you control its lifecycle (see Step 4). Saving to a file path, by
contrast, opens and closes the file internally.

### Can I call the internal section writer directly instead of `save`?

No — the section-level writer is an internal implementation detail invoked
by `PsdImage.save`. There is no documented, supported way to write a
document outside of calling `save` on a `PsdImage` instance.

## See Also

- [Working with the Core API](../how-to-work-with-psd-core-api-python/)
- [Handling PSD Core Exceptions](../how-to-work-with-psd-core-exceptions-python/)
- [Troubleshooting](../troubleshooting/)
- [Aspose.PSD FOSS for Python — Frequently Asked Questions](../faq/)
- [Aspose.PSD — Enterprise Knowledge Base](https://kb.aspose.com/psd/)