2

I iterate over all pictures in ppt using following,

for(XSLFPictureData data : ppt.getAllPictures()){
    byte[] bytes = data.getData();
    String fileName = data.getFileName();       
    int pictureFormat = data.getPictureType();                         
    System.out.println("picture : " + fileName); 
    System.out.println("pictureSize : " + data.getImageDimensionInPixels()); 
}

As described in doc: Documentation POI getImageDimensionInPixels()

How to use this method to get image size in pixels or height/length?

jrbedard
  • 3,662
  • 5
  • 30
  • 34
Dave D.
  • 737
  • 3
  • 10
  • 23
  • 2
    What is wrong with the output of `data.getImageDimensionInPixels()` that you ask on how to use this method? It would be helpful when you add the output of your script here, too. – gus27 Nov 21 '16 at 16:37
  • XSLFPictureData.getImageDimensionInPixels() is not valid method. – Dave D. Nov 21 '16 at 16:57
  • 1
    So you cannot compile your code, right? You are using the most recent version of the POI library? – gus27 Nov 21 '16 at 17:01

1 Answers1

3

I've made quite a few changes to unify the HSLF and XSLF API to Common SL - and before you might complain about breaking changes, neither XSLF nor HSLF are in the stable main jar. So with the trunk (POI 3.16) the example code would be like this:

@Test
public void bugbla() throws Exception {
    XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("51187.pptx");
    for(XSLFPictureData data : ppt.getPictureData()){
        byte[] bytes = data.getData();
        String fileName = data.getFileName();       
        PictureType pictureFormat = data.getType();                         
        System.out.println("picture : " + fileName); 
        System.out.println("pictureSize : " + data.getImageDimensionInPixels()); 
    }
}
kiwiwings
  • 3,386
  • 1
  • 21
  • 57