Cannot get background images in slide master

The slide master has two images in it.


When I iterate through the slides and the shapes these images are not there? How do I locate them?

I am having trouble locating them programmatically via the API using java. The shapes collection for this slide doesnt show them and the below code doesnt trigger either of the if statements please help;


if (slide.getBackground().getFillFormat().getFillType() == FillType.Picture)
{
//Getting the back picture
Backimg = slide.getBackground().getFillFormat().getPictureFillFormat().getPicture().getImage();

//Saving picture
BufferedImage image=Backimg.getSystemImage();

ImageType = Backimg.getContentType();
//ImageType = ImageType.s.substring(0, ImageType.indexOf("/") + 1);
ImageType = ImageType.substring(ImageType.indexOf("/") + 1,ImageType.length());

String ImagePath = “BackImage_”;
try {
ImageIO.write(image,ImageType, new File( slideIndex+ “.” +ImageType.toString()));
//Setting the desired picture format
} catch (IOException ex) {
// Logger.getLogger(NewAPi.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(ex);
}

}
else
{
if (slide.getLayoutSlide().getBackground().getFillFormat().getFillType() == FillType.Picture)
{
//Getting the back picture
Backimg = slide.getLayoutSlide().getBackground().getFillFormat().getPictureFillFormat().getPicture().getImage();

BufferedImage image=Backimg.getSystemImage();

ImageType = Backimg.getContentType();
ImageType = ImageType.substring(ImageType.indexOf("/") + 1,ImageType.length());

String ImagePath = “BackImage_”;
try {
ImageIO.write(image,ImageType, new File(slideIndex+ “.” +ImageType.toString()));
//Setting the desired picture format
} catch (IOException ex) {
// Logger.getLogger(NewAPi.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(ex);
}

}
}

Hi Piers,

I have observed your requirements and like to share that the image that you are trying to extract are available in layout slides as picture frames. Please try using following sample code on your end to serve the purpose.

public static void GetImages()
{

String path=“C:\Aspose Data\”;
Presentation pres=new Presentation(path+“da.pptx”);
ISlide slide=pres.getSlides().get_Item(0);

ILayoutSlide layout=slide.getLayoutSlide();
IShape shape=null;
for(int i=0;i<layout.getShapes().size();i++)
{
shape=layout.getShapes().get_Item(i);
if(shape instanceof IPictureFrame)
{
IPictureFrame picFrame=(IPictureFrame)shape;
{
com.aspose.slides.IPPImage Backimg = null;
Backimg = picFrame.getPictureFormat().getPicture().getImage();
String ImageType = Backimg.getContentType();
ImageType = ImageType.substring(ImageType.indexOf("/") + 1,ImageType.length());
String ImagePath = path + “Slides\Image_”;

BufferedImage image=Backimg.getSystemImage();

try
{
ImageIO.write(image,ImageType, new File(ImagePath+(i+1)+ “.” +ImageType.toString()));
//Setting the desired picture format
}
catch (IOException ex)
{
// Logger.getLogger(NewAPi.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(ex);
}

}
}

}
}

Many Thanks,

That worked for me - thank you very much for your prompt reply


Regards

Piers