Write Descriptors
Overview
The package org.aspose.psd.writedescriptors has one public class, PsdImageWriter. Its save method writes a PsdImageDocumentState to an OutputStream. It is the low-level writer that sits behind PsdImage.save, together with PsdImageLoader (package org.aspose.psd.loaders), which reads a document from a stream into a document state.
Use PsdImage.save
PsdImage.save(String) and PsdImage.save(OutputStream) are the supported way to write a document. In the library’s own tests a document that is saved without changes is written back identically, and a document with changed layer metadata contains the changes when it is loaded again. PsdImage.save(OutputStream) closes the stream that you pass in. See Core API and Layers.
The Writer and Loader Classes
| Class | Package | Role |
|---|---|---|
PsdImageWriter | org.aspose.psd.writedescriptors | Writes a PsdImageDocumentState to an OutputStream |
PsdImageLoader | org.aspose.psd.loaders | Loads a PsdImageDocumentState from an InputStream |
LayerAndMaskSectionWriter, LayerAndMaskSectionReader | org.aspose.psd | Write and read the layer and mask information section |
LayerRecordWriter, LayerRecordReader | org.aspose.psd.layers | Write and read the layer records |
BigEndianWriter, BigEndianReader | org.aspose.psd | Write and read big-endian binary data |
Tips and Best Practices
- Call
PsdImage.saveunless you are building your own tool on the document state. - Do not rely on the writer classes for anything beyond what
PsdImage.savedoes.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
You want to write a document without a PsdImage | PsdImageWriter.save needs a PsdImageDocumentState | Load the file with PsdImage and save it with PsdImage.save |
FAQ
Is PsdImageWriter the way to save a PSD?
No. Use PsdImage.save.
API Reference Summary
| Class | Description |
|---|---|
| PsdImageWriter | Writes a document state to a stream |
| PsdImageLoader | Loads a document state from a stream |
| PsdImageDocumentState | The parsed sections of a document |