PSD files are used to create images using different layers containing shapes, text, effects, etc. You may need to add several layers for inserting graphics or text by your image processing applications. Accordingly, this article covers how to create a PSD image programmatically in Java.
Java API to Create a PSD Image – Installation
Aspose.PSD for Java API supports creating, editing, or manipulating PSD and several other supported file formats. You can configure the API by downloading its JAR file from the Downloads section or with the following Maven configurations:
<repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>http://repository.aspose.com/repo/</url> </repository>
<dependency> <groupId>com.aspose</groupId> <artifactId>aspose-psd</artifactId> <version>21.7</version> <classifier>jdk16</classifier> </dependency>
Create a PSD Image using Java
You can add one or more layers to create a PSD file. For example, different layers to contain text, images, shapes, etc. Here we will be adding different shapes including a rectangle and ellipse, as well as a text layer for demonstration. You need to follow the steps below to create a PSD image using Java:
- Create a new image using the PsdImage class.
- Clear the image data and add a rectangle and ellipse drawing.
- Add a text layer with any text string.
- Write the output PSD file using the Save method.
The following code snippet explains how to create a PSD image programmatically in Java:
Explore API Features
You may take a look at the documentation to check several other features offered by the API.
Get Free Evaluation License
You can evaluate the API in full capacity without any evaluation limitations by requesting a free temporary license.
In this article, you have learned how to create a PSD image programmatically using Java. You have explored how to draw a rectangle and ellipse by specifying the coordinates and the color of the shapes. Likewise, a text layer is also added to the PSD image to explain how simply you can integrate these features in your image processing applications. Furthermore, please feel free to reach out to us at the forum in case of any queries.