Features
Overview
Aspose.PSD FOSS for Java loads, inspects and saves PSD and PSB documents. It does not render pixels. The features fall into four areas, each with its own guide.
Loading and Saving Documents
PsdImage.load(String) and PsdImage.load(InputStream) open a PSD or PSB file; PsdImage.save(String) and PsdImage.save(OutputStream) write it. PsdImage reports the width, height, bits per channel, color mode, compression and channel count. RGB, CMYK and indexed-color PSD files load, and RGB PSB files load. See Core API.
Layer Metadata
Each Layer has a name, visibility, opacity, clipping, blend mode key and position. You can change name, visibility and opacity and save the document; the changes are in the file when you load it again. Layer names are saved as ASCII text. See Layers.
Image Resources
PsdImage.getImageResources() returns the image resource blocks of a document as read-only data. See Resources.
Errors
Input with an invalid signature or header, an empty stream, or data that ends before the end of the image resources or layer sections throws PsdLoadException. See Core Exceptions.
What Is Not Supported
- The library does not render images, export to PNG or JPEG, convert formats, or decode pixels.
- Seven setters are not supported in this edition and always throw
UnsupportedOperationException:PsdImage.setActiveLayer,PsdImage.setImageResources,PsdImage.setGlobalLayerResources,PsdImage.setHasTransparencyData,Layer.setChannelInformation,Layer.setLayerMaskDataandLayer.setLayerBlendingRangesData. - Adding, removing or reordering layers through
PsdImage.setLayersis not a supported edit. Passing the same layer array back tosetLayersis accepted, but it counts as a layer edit and the writer then rewrites every layer record. PsdImage.getVersion()returns 6 for both PSD and PSB documents, andPsdImagedoes not report which of the two a file is.PsdImage.getActiveLayer()returns the first layer (ornullwhen there are no layers), not the active layer stored in the file.
Tips and Best Practices
- Start with Core API, then read Layers.
- Close the image when you are done;
close()can be called twice without harm. - Handle
PsdLoadExceptionwhere you load from a stream, and aRuntimeExceptionthat wraps it where you load from a path. - Do not edit documents whose layer names contain non-ASCII characters; see Layers.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
| Expecting a rendered bitmap | The library has no rendering, export or pixel API | Use another library for rendering; this one loads, inspects and saves PSD and PSB structure |
UnsupportedOperationException from a setter | The setter is one of the seven that this edition does not support | Do not call it; see the list above |
Layer names show ? after saving | Layer names are saved as ASCII text | Keep layer names ASCII, or do not save the document |
FAQ
Does the library need Adobe Photoshop?
No. It reads and writes the files itself.
Which Java version does it need?
Java 11 or later. The java.desktop module is needed to load indexed-color documents.
API Reference Summary
| Class | Description |
|---|---|
| PsdImage | Loads, inspects and saves a PSD or PSB document |
| Layer | A layer of the document with its metadata |
| PsdLoadException | Thrown when loading fails |