Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created February 1, 2022 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/34611e69809b5dbdcc961fe2e8c135e0 to your computer and use it in GitHub Desktop.
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
// 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