Free Support Forum - aspose.com

OutOfMemoryException creating thumbnails of slides with very large pictures

I am getting an OutOfMemoryException on .getThumbnail when attempting to convert slides with very large high-resolution pictures. I’ve allocated up to 1gig of memory for the JVM but not luck converting.


public static boolean convertPowerPointToJPG(String inputFile, String outputFolder){
try {
if(getFileExtension(inputFile).equalsIgnoreCase(“PPT”)){
Presentation pres = new Presentation(inputFile);
for(Slide s : pres.getSlides()){
try {
Dimension d = new Dimension(1024,768);
BufferedImage i = s.getThumbnail(d);
System.out.println("converting slide " + s.getSlidePosition());
File outputfile = new File(outputFolder+“page_” + ZERO_FORMATTER.format(s.getSlidePosition())+JPG_EXTENSION);
ImageIO.write(i, “jpg”, outputfile);
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
} else {
PresentationEx pres = new PresentationEx(inputFile);
for(SlideEx s : pres.getSlides()){
try {
Dimension d = new Dimension(1024,768);
BufferedImage i = s.getThumbnail(d);
System.out.println("converting slide " + s.getSlideNumber());
File outputfile = new File(outputFolder+“page_” + ZERO_FORMATTER.format(s.getSlideNumber())+JPG_EXTENSION);
ImageIO.write(i, “jpg”, outputfile);
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
}
} catch (Exception e){
e.printStackTrace();
return false;
}
return true;
}

Hi Joseph,


Thanks for inquiring Aspose.Slides.

I like to share that OutOfMemory exception is thrown when stack is over flown. I suggest you to please try the latest version of Aspose.Slides for Java 6.9.1 on your end along with some enhancement in stack size afterwards. If there is still an issue then please share the sample presentation with us for further investigation.

Many Thanks,