Write Descriptors

Write Descriptors

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

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:

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

IssueCauseFix
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 lengthA string value exceeds 255 bytesSee 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/MethodDescription
PsdImage.save(file_path) / PsdImage.save(stream)Saves the document

See Also