Free Support Forum - aspose.com

Quality parameter for the image file cretaed form a PPT

Hi,

Is there any parameter that can be used to set/enhance the quality of the image file created from the PPT. Basically i need to generate a Thumbnail of the first slide. so i am using Aspose Slides to convert the first slide of a ppt to a thumbnail image(jpeg of size 80x80). The quality of the thumbnail image generated is not very impressive. Is there a way to enhance the quality by setting some parameter on com.aspose.slides.Slide class. My current code snippet is as follows.

public boolean convert(String pptFileName){

Presentation pres;

try {

//Instantiate a Presentation object that represents a PPT file

pres = new Presentation(new FileInputStream(new File(pptFileName)));

// Accessing a slide using its slide position

Slide slide = pres.getSlideByPosition(1);

// Getting the thumbnail image of the slide of a specified size

BufferedImage image = slide.getThumbnail(new Dimension(80, 80));

// Saving the thumbnail image in jpeg format

ImageIO.write(image, "jpeg", new File(pptFileName.substring(0,

pptFileName.lastIndexOf("\\"))

+ "\\" + pptFileName.substring(pptFileName.lastIndexOf("\\")+1,pptFileName.lastIndexOf('.')) + ".jpg"));

} catch (Exception e) {

System.out.println("Exception occurred while file conversion to pdf.");

e.printStackTrace();

}

return true;

}

Hi,

Thanks for considering Aspose.Slides.

We regret to inform you that there is no such parameter defined in Aspose.Slides that ensures the quality of thumbnail. However, you can set the different scaling levels of resolution in it.

We are sorry for your inconvenience,

Hi,

thanks for your response. however i am using Aspose.Slides for JAVA and not for Aspose.NET . so does your response hold true for java as well?

Also can you please provide me some code sample for setting the different scaling levels of resolution .

My code snippet is as follows:

public boolean convert(String pptFileName){

Presentation pres;

try {

//Instantiate a Presentation object that represents a PPT file

pres = new Presentation(new FileInputStream(new File(pptFileName)));

//Accessing a slide using its slide position

Slides slides = pres.getSlides();

int lastSlide = slides.getLastSlidePosition();

int count = 1;

Slide slide = pres.getSlideByPosition(count);

//Getting the thumbnail image of the slide of a specified size

BufferedImage image=slide.getThumbnail(new Dimension(80,80));

//Saving the thumbnail image in jpeg format

ImageIO.write(image,"jpeg", new File(pptFileName+".jpg"));

} catch (Exception e) {

System.out.println("Exception occurred while file conversion to pdf.");

e.printStackTrace();

}

return true;

}

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please use the code snippet below to generate the thumbnail image at different scaling levels. In slide.getThmbnail() method, you provide the scaling factor in arguments section. whatever value, you will provide, the thumbnail generated will conform that.

try

{

//Instantiate a Presentation object that represents a PPT file

Presentation pres = new Presentation(new FileInputStream(new File("demo.ppt")));

//Accessing a slide using its slide position

Slide slide = pres.getSlideByPosition(1);

//Getting the thumbnail image of the slide of a specified size

// Setting parameter to 1f sets the thumbnail to size of slides, if it is 2f then the

// thumbnail generated is twice the size of slide

BufferedImage image=slide.getThumbnail(1f,1f);

//Saving the thumbnail image in jpeg format

ImageIO.write(image,"jpeg", new File("C:\\thumbnail.jpg"));

}

catch(Exception ex)

{

System.out.println(ex.toString());

}

Thanks and Regards,