Sections

Overview

A PSD or PSB file consists of five sections: the header, the color mode data, the image resources, the layer and mask information, and the image data. The package org.aspose.psd.sections has a public class for each, and PsdImageDocumentState holds the parsed sections of one document. They are low-level building blocks that the loader and writer use. PsdImage keeps its parsed sections internal, so ordinary code reads the document through PsdImage and Layer instead (see Core API and Layers).


The Section Classes

ClassModels
PsdHeaderThe header: width, height, channels, bit depth, color mode, version and whether the document is a large document (PSB)
ColorData, PsdColorDataInfoThe Color Mode Data section and its read-only view; PsdColorDataKind says how the payload was interpreted
ImageResourcesSectionThe Image Resources section and its resource blocks
LayerAndMaskSectionThe Layer and Mask Information section, including the raw bytes that are preserved when a document is saved without changes
ImageData, ImageDataStructure, PsdImageDataInfoThe merged image data as a compression header plus raw payload bytes, its validated layout and a read-only summary; ImageDataKind identifies the layout (Raw, Rle, Zip, Unknown or RAW_PRESERVED)
PsdImageDocumentStateHolds the parsed header, color data, image resources, layer and mask section and image data of one document
SeekOriginSeek origins (BEGIN, CURRENT, END) used by the binary reader and writer

Tips and Best Practices

  • Use PsdImage for loading, inspecting and saving; use the section classes only when you need to read the structure of a file yourself.
  • The sections keep raw bytes so that a document that is saved without changes is written back unchanged.

Common Issues

IssueCauseFix
You cannot get the PsdHeader from a PsdImagePsdImage keeps its sections internalUse the PsdImage getters for width, height, bits per channel, color mode and compression

FAQ

Do I need these classes to edit a layer?

No. Edit layers through PsdImage.getLayers(); see Layers.


API Reference Summary

ClassDescription
PsdHeaderThe document header
ColorDataThe color mode data section
ImageResourcesSectionThe image resources section
LayerAndMaskSectionThe layer and mask information section
ImageDataThe merged image data
PsdImageDocumentStateThe parsed sections of a document

See Also