Created
February 1, 2022 22:22
-
-
Save aspose-com-gists/34611e69809b5dbdcc961fe2e8c135e0 to your computer and use it in GitHub Desktop.
How to create PSD file in Java | How to make a PSD without photoshop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a new image from scratch. | |
PsdImage image = new PsdImage(450, 450); | |
// Fill image data | |
Graphics graphics = new Graphics(image); | |
graphics.clear(Color.getWhite()); | |
// Draw a rectangle | |
graphics.drawRectangle(new Pen(new SolidBrush(Color.getBlue())), new Rectangle(10, 30, 80, 40)); | |
// Draw a ellipse shape by specifying the Pen object, color and coordinates | |
graphics.drawEllipse(new Pen(new SolidBrush(Color.getRed())), new Rectangle(60, 80, 130, 90)); | |
// Add a text layer | |
image.addTextLayer("Sample text", new Rectangle(150, 220, 100, 130)); | |
// Save output PSD file | |
image.save("CreatePSD.psd"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment