Free Support Forum -

Picture IDs for identical JPGs


I am creating Pictures from identical JPEG files, however after I add them to the presentation, only the first has a valid picture ID. The first has an ID of 2 and all the rest have an ID of 1.

I have attached a simple test program, so you can see what I am doing. This test program uses the same file for each Picture. My actual application uses identical images but they are in different files. The behaviour is the same. How does Aspose.Powerpoint know that these images are the same?

Is there something I am doing wrong?

I am using the most recent version of Aspose Powerpoint for Java (

Thank you,
Randy Stegbauer

Aspose.PowerPoint checks image size and crc32. The same picture can’t be added again.

Pictures.add function returns id of picture. It can be id of a new image or old one.

In you example picture2 and picture3 will not be added to a presentation and add()

function will return id of picture1.

I little changed code to make it work.

InputStream is1 = new FileInputStream(“picture.jpg”);

Picture picture1 = new Picture(pres, is1);

int id1 = pres.getPictures().add(picture1);

picture1 = pres.getPictures().get(id1);

System.out.println("Picture ID 1: " + picture1.getPictureId());

InputStream is2 = new FileInputStream(“picture.jpg”);

Picture picture2 = new Picture(pres, is2);

int id2 = pres.getPictures().add(picture2);

picture2 = pres.getPictures().get(id2);

System.out.println("Picture ID 2: " + picture2.getPictureId());

InputStream is3 = new FileInputStream(“picture.jpg”);

Picture picture3 = new Picture(pres, is3);

int id3 = pres.getPictures().add(picture3);

picture3 = pres.getPictures().get(id3);

System.out.println("Picture ID 3: " + picture3.getPictureId());


Thank you for the quick response. I understand this now and my problem is solved.

I wanted to clarify something so others may not be confused.

When I did "picture1 = pres.getPictures().get(id1);" from above an IndexOutOfBoundsException was thrown. I think this should have called getPictureById(id1) instead. Right?

Thank you,
Randy Stegbauer.

Sure, getPictureById(id). That’s my mistake.