Maick
Maick

Reputation: 45

Resize/compress picture using Apache POI hslf - PowerPoint

Hi I build a powerpoint presentation using apache poi and add a lot of images to the presentation.

private void addImage(SlideShow slideShow, Sheet slide, File image, int x, int y, int w, int h) {
    try {
        int idx = slideShow.addPicture(image, Picture.JPEG);
        Picture pict = new Picture(idx);
        pict.setAnchor(new Rectangle(x, y, w, h));
        slide.addShape(pict);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

The function works and I get a ppt presentation in the end, but the ppt file is too big and at another PC I get a heap space error. So I would like to resize / compress my images in the slides. I have four pictures on each slide - so they don't need to have the original resolution.

Is there a build in function in poi to do this? Something like

pict.resize(width, height);

I'm using apache poi 3.7

thx in advance

Upvotes: 0

Views: 2593

Answers (1)

kiwiwings
kiwiwings

Reputation: 3446

POI doesn't modify the pictureData itself. You'll need to resample it yourself before.

Upvotes: 2

Related Questions