1. Products
  2.   Aspose.PSD
  3.   Aspose.PSD FOSS for Java

Aspose.PSD FOSS for Java

Open-source Java library for loading, inspecting, and saving PSD and PSB files with layer metadata access. MIT licensed, no Adobe Photoshop required.

Open-Source Java Library for PSD and PSB Files

Aspose.PSD FOSS for Java is a free, MIT-licensed library for loading, inspecting, and saving Adobe Photoshop PSD and PSB files from Java without Adobe Photoshop. Its API is centered on PsdImage and Layer: load a document, read its dimensions, color mode, bit depth, compression and channel count, walk its layers, and read its image resources. A document can be saved back to a file or a stream. In the library’s own tests an unmodified document is written back byte for byte. The layer metadata that you can change and save is the name, visibility and opacity; position, clipping and blend mode also have setters. The library does not render images, export to PNG or JPEG, or decode pixels. The library has no third-party runtime dependency and needs only the JDK; indexed-color documents need the java.desktop module because the library uses java.awt.Color. It is compiled for Java 11 and was run on Java 11, 17 and 21. Add it to your Maven build as org.aspose:aspose-psd-foss:26.11.0. For the enterprise product family, see Aspose.PSD — Enterprise Product Family.

Load and Inspect PSD and PSB Files

  • PsdImage.load(String) opens a PSD or PSB file from a path; PsdImage.load(InputStream) loads from a stream and declares the checked PsdLoadException
  • PsdImage reports getWidth(), getHeight(), getBitsPerChannel(), getColorMode(), getCompression() and getChannelsCount()
  • RGB, CMYK and indexed-color PSD files load, and RGB PSB files load
  • Image.load returns an Image that is a PsdImage for a PSD or PSB file

Read and Catalog Design Files

  • Check that files have a readable header, layers and image resources before handing them to another process; a successful load does not prove that the merged image data is complete
  • Build an inventory of document sizes, color modes and layer counts
  • Load PSD and PSB files with the same call; PsdImage does not report which of the two a file is

Work with Layers

  • PsdImage.getLayers() returns the Layer objects of the document
  • Each Layer exposes getName(), isVisible(), getOpacity(), getClipping(), getBlendModeKey() and its position (getLeft(), getTop(), getRight(), getBottom())
  • getOpacity() returns a byte that holds a value from 0 to 255
  • Layer.getChannelsCount() reports how many channels a layer carries

Audit Layer Structure

  • List layer names, visibility and blend modes for a design review
  • Find hidden layers or layers with reduced opacity
  • Compare the layer structure of two versions of a file

Edit Layer Metadata and Save

  • Layer.setName(String), setVisible(boolean) and setOpacity(byte) change a layer’s metadata
  • PsdImage.save(String) and PsdImage.save(OutputStream) write the document; reloading the saved file shows the changes; save(OutputStream) closes the stream you pass in
  • In the library’s own tests, a document that is loaded and saved without changes is written out byte for byte
  • Layer names are saved as ASCII text of at most 255 characters; other characters become ?

Scripted Metadata Changes

  • Hide or show layers in a batch of files
  • Adjust layer opacity across many files for consistency
  • Rename layers whose names are ASCII

Read Image Resources and Handle Errors

  • PsdImage.getImageResources() returns the image resource blocks of the document as read-only data
  • 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 from PsdImage.load(InputStream); PsdImage.load(String) reports the same problems as a RuntimeException that wraps it
  • A missing file is a FileNotFoundException; a null path is an IllegalArgumentException
  • Some setters are not supported in this edition and throw UnsupportedOperationException, for example PsdImage.setImageResources and Layer.setLayerMaskData

Diagnose Problem Files

  • Find out why a file fails to load from the exception type and message
  • Keep unsupported edits out of your code by checking the reference first

Add the Library to Your Maven Build

The library is published on Maven Central. Add this dependency to your project:

<dependency>
  <groupId>org.aspose</groupId>
  <artifactId>aspose-psd-foss</artifactId>
  <version>26.11.0</version>
</dependency>

Frequently Asked Questions

What is the license of Aspose.PSD FOSS for Java?

It is MIT licensed. You can use, modify and redistribute it under the terms of the MIT license, including in commercial products.

How do I install it?

Add org.aspose:aspose-psd-foss:26.11.0 to your Maven build. The library is published on Maven Central and has no third-party runtime dependencies.

Which Java version does it need?

Java 11 or later. It was built for Java 11 and run on Java 11, 17 and 21. The java.desktop module (for java.awt.Color) is needed to load indexed-color documents.

Which files can it open?

PSD and PSB (large document) files. RGB, CMYK and indexed-color PSD files and RGB PSB files were tried. Both types load with PsdImage.load.

Does it render or convert PSD files?

No. The library has no rendering, export, conversion or pixel-decoding API. It loads, inspects and saves PSD and PSB structure.

Which setters are not supported?

PsdImage.setActiveLayer, setImageResources, setGlobalLayerResources and setHasTransparencyData, and Layer.setChannelInformation, setLayerMaskData and setLayerBlendingRangesData always throw UnsupportedOperationException.

  

Support and Learning Resources