How the PSD Section Classes Fit Together in Java
View as Markdown

How the PSD Section Classes Fit Together in Java

A PSD or PSB file has five sections: header, color mode data, image resources, layer and mask information, and image data. The package org.aspose.psd.sections has a class for each. This guide explains how to choose between them and PsdImage.

Step-by-Step Guide

Step 1: Decide Whether You Need Sections

If you want the width, height, bit depth, color mode or compression of a document, call the getters of PsdImage. If you want layers, call PsdImage.getLayers(). PsdImage keeps its parsed sections internal, so these getters are the supported way to read them.


Step 2: Know What Each Class Models

PsdHeader models the header, ColorData the color mode data, ImageResourcesSection the image resources, LayerAndMaskSection the layer and mask information and ImageData the merged image data. PsdImageDocumentState holds the parsed sections of one document.


Step 3: Use the Read-Only Views

PsdColorDataInfo and PsdImageDataInfo are read-only views of the color data and the image data. ImageDataKind says how the image data is laid out and PsdColorDataKind says how the color data was interpreted.

Things to Know

  • These classes are low-level building blocks of the loader and writer.
  • The sections keep raw bytes, so a document that you save without changes is written back identically in the library’s tests.

See Also