How to Get an Image from a 3D Model in a PowerPoint Presentation in Java?

My test PPTX has just one 3D Model object. When I call presentation.getImages().get_item(0) I get the image that represents the 3D Model and I can save that as a PNG file.

However, when I get the slide and the shape (3D Model) it returns com.aspose.slides.GraphicalObject but I cannot find a way to get the image from it. It also doesn’t have any reference to the image that I get from the last step. How do I get an image for a 3D Model object?

This is a code snippet:

Presentation presentation = new Presentation("C:\\Temp\\test.pptx");
IPPImage image = presentation.getImages().get_Item(0);
FileOutputStream fos = new FileOutputStream("C:\\Temp\\image1.png");
fos.write(image.getBinaryData());
fos.close();  // Saved the image. This part is fine.
 
IShape shape = presentation.getSlides().get_Item(0).getShapes().get_Item(0);
System.out.println(shape.getClass().getName());  // prints com.aspose.slides.GraphicalObject
// Now, I cannot get the image from this shape object.

I can upload my test PPTX but it’s just a simple one slide presentation with a 3D Model object.

Thank you,
Robert.

@raungnaing,
Thank you for contacting support. To get the image from your shape object, you can use the getThumbnail method. The following code snippet shows you how to do this:

IShape shape = presentation.getSlides().get_Item(0).getShapes().get_Item(0);
BufferedImage thumbnail = shape.getThumbnail(ShapeThumbnailBounds.Shape, 1.5f, 1.5f);
File imageFile = new File("model_image.png");
ImageIO.write(thumbnail, "png", imageFile);

Documents: Create Shape Thumbnails

@Andrey_Potapov - It works great! Thank you so much for the quick reply.

@raungnaing,
Thank you for using Aspose.Slides.