We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Performance issue when rendering slide to graphics

Hello, I’m testing the lib to check if my company is going to go for this or not and currently I’ve been having some serious issues with the feature of rendering slides to graphics.


When trying to do this with the attached pptx, it takes more than one minute to render all slides to graphics. Sometimes it takes even longer and end up using all memory and throwing a GC Overhead exception.

This is my code:
public void testMethod(){
for (int i = 0, len = slide.size(); i < len; i++) {
File image = new File(getPathToSave(version.getId(), item.getId(), i));
Dimension2D pgsize = pres.getSlideSize().getSize();

long millis = System.currentTimeMillis();
writeSlideToFile(image, pres.getSlides().get_Item(i), (int) pgsize.getWidth(), (int) pgsize.getHeight());
System.out.println(System.currentTimeMillis() - millis);
}
}

private void writeSlideToFile(Object out, ISlide slide, int pageWidth, int pageHeight) throws IOException {

BufferedImage img = new BufferedImage(pageWidth, pageHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
graphics.fill(new Rectangle2D.Float(0, 0, pageWidth, pageHeight));

slide.renderToGraphics(false, graphics, img.getWidth(), img.getHeight());
if (out instanceof File)
javax.imageio.ImageIO.write(img, “png”, (File) out);
if (out instanceof ByteArrayOutputStream)
javax.imageio.ImageIO.write(img, “png”, (ByteArrayOutputStream) out);


}

The execution takes too long to go through the line "slide.renderToGraphics(false, graphics, img.getWidth(), img.getHeight()); ". Am I doing this wrong or is this an Aspose issue?


I’m using Windows 7-64bits, Java 7, Aspose 16.2(trial version), Intel i5-2400 3.1ghz

Hi Luciano,


Thank you for your interest in Aspose.Slides.

I have observed your comments and like to share with you that on my end, image of all slides are created in about 68 seconds. I have tested it on a system with specifications as, Windows 10-64 bits, JDK 1.8, Aspose.Slides for Java 16.3.0, Intel i3 processor and 4 gb RAM. The code I have used to generate thumbnails is,

Presentation pres = new Presentation(“D:\160413_PPT_Export_Vorlage_v2.pptx”);
ISlide pageSlide = null;
long st = System.currentTimeMillis();
for (int i = 0; i < pres.getSlides().size(); i++) {
pageSlide = pres.getSlides().get_Item(i);
BufferedImage bufferedImage = pageSlide.getThumbnail(1.0f, 1.0f);
ImageIO.write(bufferedImage, “jpeg”, new FileOutputStream(“D:\160413_PPT_Export-” + (i + 1) + “.jpg”));
}
long end = System.currentTimeMillis();
System.out.println(“TOTAL TIME ms:” + (end - st));

I hope this will be helpful. Please share if I may help you further in this regard.

Best Regards,

Thanks for your attention, this problem was fixed when I increased the memory that my program could use up to 1GB.

Hi Luciano,


Thank you for your valuable feedback.

We are glad to know that your issue is resolved and things have started working on your end.

Please feel free to contact us if we can be of any help to you.

Best Regards,