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

# Write Descriptors

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

## Overview

`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.

---

### Saving to a File Path or Stream

```python
from aspose_psd_foss.psdimage import PsdImage

image = PsdImage.load(input_path)
image.save("output.psd")
```

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

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

---

### Choosing a Container Format

There is no public API to choose the output container format on save — a
save always mirrors whichever format (`is_large_document` / `is_psb`)
the document was loaded with. There is no supported conversion path
between PSD and PSB in this FOSS build.

---

### Tips and Best Practices

- Call `save` before disposing the image — `save` on a disposed
  `PsdImage` raises `RuntimeError`.
- The internal section-level writer invoked by `save` is not a
  documented or supported entry point on its own; always go through
  `PsdImage.save`.

---

### Common Issues

| Issue | Cause | Fix |
|---|---|---|
| `RuntimeError: PsdImage has been disposed.` | `save` was called after `dispose()` (or after a `with` block exited) | Call `save` before disposing the image |
| `PsdSaveException` about a Pascal string length | A string value exceeds 255 bytes | See [Core Exceptions](../psd-core-exceptions/) |

---

### FAQ

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

No — passing a stream to `save` leaves it open afterward so you control
its lifecycle. Saving to a file path, by contrast, opens and closes the
file internally.

#### Can I produce a PSB file from a document loaded as PSD?

No — there is no public API to override the container format on save; it
always mirrors the loaded document's own format.

---

### API Reference Summary

| Class/Method | Description |
|---|---|
| `PsdImage.save(file_path)` / `PsdImage.save(stream)` | Saves the document |

## See Also

- [Core API](../core-api/)
- [Core Exceptions](../psd-core-exceptions/)
- [Aspose.PSD — Enterprise Documentation](https://docs.aspose.com/psd/)