Free Support Forum -

Adding a picture to slide combines or merges the picture with the picture in the master slide

Hi There - I was trying to add a picture to a slide but unfortunately I am getting and image that combines with the image in the master slide.

Detail - I have a ppt template with master slide and that master slide had a picture for the background.
Now I am adding another picture exists in a path say c:\tmp\xxx.png. I am using below code to add the picture to the slide. Please help me how can I avoid merging the picture with the background image exists on the master slide, so that I can only add the picture I am interested in.

Presentation pres=new Presentation(new BufferedInputStream(new InputStream(File("C:\\tmp\\MyPresentationTemplate.ppt")); // This is my template
final Slides slides=pres.getSlides();
for (Slide slide : slides)

    final BufferedImage originalImage = File("C:\\tmp\\xxx.png"));
    final  ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(originalImage, "png", baos);
    final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    final int picIndex= pres.getPictures().add(new Picture(pres, bais));
    final Shape shp = slide.getShapes().addPictureFrame(ShapeType.Rectangle.getId(), 0, 0, 3000, 3000);


Hi Tushar,

Thank you for inquiring Aspose.Slides.

I have observed your comments and like to request you to share with us the source file, generated output file and a presentation created by PowerPoint to explain your expected output. I also request you to please try using Aspose.Slides for Java 15.5.1 on your end first. Please share these requested files so that I may investigate it further on my end.

If the issue persists then please let us know. We will be happy to assist you further.

Best Regards,