Reference to picture


I have a problem with pictures. What I need is a reference to a picture. Fisrt I export all Images->

for(int i=1; i<=pres.getPictures().size(); i++) {
pres.getPictures().getPictureById(i).write(new FileOutputStream(new File(“c:\apose\img” + i + “.jpg”)));

What I now need to know is, where the picture come from, I mean the SlidePosition and ShapePosition.


All the pictures are present in Presentation.getPictures() collection, which contains instances of Picture objects.

However, in order to show the Picture object on a slide, a PictureFrame object is created and picture id of the required picture to be shown is assigned to it either through its constructor or PictureFrame.setPictureId() method.

It means, if you want to know the X, Y position of some picture on the slide, you will access the PictureFrame shape having your picture id and then use PictureFrame.getX() and PictureFrame.getY() methods.

Please also read this link

OK, now I have the PictureID,
but I need to know wich Slide/Shape the picture is associated to and the PictureId doesn’t give any information to that.
For example: I want to access -> pres.getSlideByPosition(i).getShapes().get(j).getWidth()
and it is an PictureFrame, how do I know wich picture ->

pres.getPictures().getPictureById(i).write(new FileOutputStream(new File(“c:\img.jpg”))))

that pictureFrame is?

It ist necessary for me to know, where all these pictures come from (Slide / Shape).

…sorry for my english…

Please see this code in JAVA, it finds the reference to PictureFrame having the PictureID provided by us.

The source presentation used by me is attached alongwith the code.


import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.util.TreeMap;

import javax.imageio.ImageIO;
import com.aspose.slides.*;

public class JClsPPtPractice {

public static void main(String[] args) {
String srcFile="c:\\srcWhichPictureFrame.ppt";


private static void GetPictureFrameForGivenPICID(String srcFile, int PICID)
//Open the source presentation and slide
Presentation srcPres=new Presentation(new FileInputStream(new File(srcFile)));
Slide sld=srcPres.getSlideByPosition(1);

//Get the reference to shapes collection
Shapes shps=sld.getShapes();

//Get the count of shapes in shapes collection
int shpCount=shps.size();
Shape shp=null;
PictureFrame pf=null;

//Iterate all shapes, if shape is a pictureframe then check its pictureid
//with our picture id, if matches, break the loop
for(int i=0; i<shpCount; i++)

if(shp instanceof com.aspose.slides.PictureFrame)



//at this point we have picture frame in pf having our picture id
catch(Exception ex)



First many thanks for the assistance,

now I have still another question:


returns not only pictures, it returns also *.wma *.avi and the comparison

if(pres.getSlideByPosition(i).getShapes().get(j) instanceof com.aspose.slides.PictureFrame) {}

returns true although the Shape isn’t a PictureFrame seperate in VideoFrame or AudioFrame

Is that possible? Can I intercept this?


if(pres.getSlideByPosition(i).getShapes().get(j).getClass() == com.aspose.slides.PictureFrame.class) {}

OK, np,

will you develop classes to get videos and audio files?