How to Read Image Resources of a PSD Document in Java
This guide shows how to read the image resource blocks of a document. The resource blocks are read-only data in this edition.
Step-by-Step Guide
Step 1: Add the Library
<dependency>
<groupId>org.aspose</groupId>
<artifactId>aspose-psd-foss</artifactId>
<version>26.11.0</version>
</dependency>Step 2: Load the Document
Load the file with PsdImage.load(String).
Step 3: Get the Resource Blocks
Call getImageResources(). It returns an array of ResourceBlock. On the library’s test files it returns 26 blocks for basic-rgb.psd and 28 for resources.psd.
Step 4: Read a Block
Each ResourceBlock has getId(), getName(), getSignature(), getSize() and getDataSize(). The ids are the identifiers that the PSD format defines for image resources.
Things to Know
PsdImage.setImageResourcesis not supported and always throwsUnsupportedOperationException; you cannot replace the resource blocks of a document.- The other resource classes (
UnknownResource,PsdResourceInfo,PsdResourceKind,IndexedColorPalette) are building blocks that the loader and writer use.