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.setLayerMaskData and Layer.setLayerBlendingRangesData.
  • Adding, removing or reordering layers through PsdImage.setLayers is not a supported edit. Passing the same layer array back to setLayers is 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, and PsdImage does not report which of the two a file is.
  • PsdImage.getActiveLayer() returns the first layer (or null when 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 PsdLoadException where you load from a stream, and a RuntimeException that wraps it where you load from a path.
  • Do not edit documents whose layer names contain non-ASCII characters; see Layers.

Common Issues

IssueCauseFix
Expecting a rendered bitmapThe library has no rendering, export or pixel APIUse another library for rendering; this one loads, inspects and saves PSD and PSB structure
UnsupportedOperationException from a setterThe setter is one of the seven that this edition does not supportDo not call it; see the list above
Layer names show ? after savingLayer names are saved as ASCII textKeep 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

ClassDescription
PsdImageLoads, inspects and saves a PSD or PSB document
LayerA layer of the document with its metadata
PsdLoadExceptionThrown when loading fails

See Also