We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to properly insert multiple images (PNG) in to a layer and then


I’m using PNG images that are being rendered and I would like to have an option to save them in to the PSD format. I had trouble finding a way to do it properly in the documentation. Maybe I’m blind, but could somebody please point me in the right direction?

Thank you.


Edit: Forgot to mention, I’m using JAVA


Please check the following article https://docs.aspose.com/psd/net/creating-opening-and-saving-images/#load-image-as-layer-from-a-stream

Also, here is Java Version

    public class Main {
        public static void main(String[] args) {

    public static void openAsLayer (String dataDir) {
        String outputFilePath = dataDir + "PsdResult.psd";

        String[] filesList = new String[]{

        try (PsdImage image = new PsdImage(200, 200)) {
            for (String s : filesList) {
                String filePath = dataDir + s;
                try (InputStream stream = new FileStream(filePath, FileMode.Open).toInputStream()) {
                    Layer layer = null;

                    try {
                            layer = new Layer(stream);
                        } catch (Exception e) {
                            if (layer != null) {
                            throw e;
                    } catch (IOException e) {
                        throw new RuntimeException(e);

Aspose.PSD can not open files as Png, Jpeg or any other formats, but it can easily open these types of images as layer. And then the PSD file can be saved.

Thanks, this helped a lot!

One more, maybe a stupid question.
I came across Aspose.Imaging and I was wondering, do I have to always open the image file from directory or can I somehow convert it from a variable, for example a buffered image?

@dqpowered you can try to load whole file to the byte array and then use it for the stream. So, there are 2 options:

  1. Load from file
  2. Load from stream

If you did it differently by other product, please provide the code snippet. Possible we will add new cases for doing this.

Got it working with your help, so thank you once again.

I’m using “our” own node concept of visual coding which has a final render node that gets input from all the nodes that connect to it. That could be for example color, background color or custom layer (single image, image grid, random distribution grid, etc.) With using your help I managed to export all the separate layers in one PSD file and open it in Photoshop. There are still some small bugs, but that’s something I can fix in a few minutes.

Thank you!

1 Like