Resources
Resources
A loaded PsdImage exposes its image resource blocks — metadata-style
entries such as grids, guides, and ICC profile payloads — through two
read-only views, plus a separate summary for indexed color palettes.
Listing Resource Blocks
PsdImage.image_resources returns a PreservedResourceBlock per
resource, with the raw resource ID, name, and byte size:
from aspose_psd_foss.psdimage import PsdImage
from aspose_psd_foss.resources.imageresourceids import ImageResourceIds
image = PsdImage.load(input_path)
for block in image.image_resources:
print(f"ID: {block.id}, name: {block.name!r}, size: {block.size} bytes")PsdImage.resources returns a separate PsdResourceInfo summary per
resource instead, adding a kind classification — in this FOSS build
kind is always PsdResourceKind.UNKNOWN, since this build’s resource
parser does not decode specific resource IDs into semantic properties.
Recognizing Known Resource IDs
Since kind is not semantically resolved, recognize a specific resource
by comparing block.id against the constants in ImageResourceIds:
for block in image.image_resources:
if block.id == ImageResourceIds.ICC_PROFILE:
print(f"Found an ICC profile resource ({block.data_size} bytes)")Reading an Indexed Color Palette
If the document’s color data is palette-based, PsdImage.indexed_palette
returns its entries:
palette = image.indexed_palette
if palette is not None:
print(f"Palette entries: {len(palette.entries)}")Tips and Best Practices
PsdImage.image_resources’ getter works for listing resources, but its setter raisesNotSupportedException— resources are read-only in this FOSS build.PsdImage.has_icc_profile,is_icc_profile_untagged, andglobal_angleare fixed placeholder values in this FOSS build (alwaysFalse,None, and0respectively) regardless of the loaded document’s actual content — use the resource-ID comparison pattern above if you need to detect these resources yourself.PreservedResourceBlock.save()raisesNotImplementedErrorif called directly — resources round-trip automatically when you callimage.save()on the whole document.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
image.indexed_palette is None | The document’s color data kind is not INDEXED_PALETTE | Only indexed-color documents carry a palette |
NotSupportedException setting image.image_resources | The setter is not supported in this FOSS build | Treat image_resources as read-only |
has_icc_profile / is_icc_profile_untagged / global_angle never change | These 3 properties are hardcoded placeholder stubs in this FOSS build | Compare block.id against ImageResourceIds instead (see above) |
FAQ
What’s the difference between image_resources and resources?
Both list the same underlying resource blocks, but as different object
types: image_resources returns PreservedResourceBlock objects (raw
ID/name/size, used for round-tripping), while resources returns
PsdResourceInfo summaries (adds a kind classification, currently
always UNKNOWN).
Can I modify or remove an image resource?
No — image_resources’ setter raises NotSupportedException, and
PreservedResourceBlock.save() raises NotImplementedError if called
directly. Resources are read-only in this FOSS build.
API Reference Summary
| Class/Method | Description |
|---|---|
PsdImage.image_resources | Raw resource blocks (PreservedResourceBlock, read-only) |
PsdImage.resources | Resource summaries (PsdResourceInfo, kind always UNKNOWN) |
PsdImage.indexed_palette | Indexed color palette summary, when present |
ImageResourceIds | Known resource ID constants for comparison against resource_id/id |