Sections
Sections
A loaded PsdImage exposes read-only summary objects for the structural
sections of a PSD/PSB document — the header, the color data section, the
image data section, and the image resources section — all through typed
properties, without requiring any manual byte-level parsing.
Inspecting the Header Section
PsdImage.header returns a PsdHeader with the document’s raw
structural fields. PsdHeader.version is the raw PSD container version
(1 for PSD, 2 for PSB) — this is a different property from the unrelated
PsdImage.version, which is a fixed API version number, not a file
format value.
from aspose_psd_foss.psdimage import PsdImage
image = PsdImage.load(input_path)
header = image.header
print(f"Size: {header.width}x{header.height}, channels: {header.channels}")
print(f"Bit depth: {header.bit_depth}, raw container version: {header.version}")
print(f"Is PSB: {header.is_large_document}")Inspecting the Color Data Section
PsdImage.color_data_info returns a PsdColorDataInfo summary; kind is
a PsdColorDataKind value (NONE, INDEXED_PALETTE, RGB_PAYLOAD,
CMYK_PAYLOAD, or RAW_PRESERVED).
if image.has_color_mode_data:
color_info = image.color_data_info
print(f"Color data kind: {color_info.kind}, raw bytes: {color_info.raw_data_length}")Inspecting the Image Data Section
PsdImage.image_data_info returns a PsdImageDataInfo summary
describing how the merged pixel data is encoded; image.compression
reports the same encoding via a separate CompressionMethod enum.
data_info = image.image_data_info
print(f"Compression: {image.compression}, data kind: {data_info.kind}")
print(f"Uses prediction: {data_info.uses_prediction}")Inspecting the Image Resources Section
PsdImage.resources, resource_count, and has_image_resources surface
the image resources section’s contents. See
Resources for the full resources API.
print(f"Resource count: {image.resource_count}")Tips and Best Practices
PsdHeaderand its related section summaries (PsdColorDataInfo,ColorData,PsdImageDataInfo) are all read-only in this FOSS build — there are no public setters on any of their properties.- Don’t confuse
PsdHeader.version(the real PSD/PSB container version) withPsdImage.version(an unrelated, fixed API version number that is always6). - Check
image.has_color_mode_databefore readingcolor_data_info— a document without color mode data still returns a summary object, but its fields may not be meaningful.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
header.color_mode doesn’t match image.color_mode | PsdHeader.color_mode is the raw integer field from the file; PsdImage.color_mode is the strongly typed ColorModes enum built from it | Use image.color_mode for a typed value; use header.color_mode only if you need the raw integer |
color_data_info.indexed_palette is None | The document’s color data kind is not INDEXED_PALETTE | Only indexed-color documents carry a palette — check color_data_info.kind first |
FAQ
Can I modify the header, color data, or image data sections directly?
No — PsdHeader, PsdColorDataInfo, ColorData, and PsdImageDataInfo
are all read-only summary objects in this FOSS build.
What’s the difference between image.compression and image.image_data_info.kind?
They describe the same underlying encoding through two separate enums:
image.compression returns a CompressionMethod value, while
image.image_data_info.kind returns an ImageDataKind value.
API Reference Summary
| Class/Method | Description |
|---|---|
PsdImage.header | Document header summary (PsdHeader) |
PsdImage.color_data_info / parsed_color_data | Color data section summary (PsdColorDataInfo / ColorData) |
PsdImage.image_data_info / image_data_kind / compression | Image data section summary |
PsdImage.resources / resource_count / has_image_resources | Image resources section summary |