Creating Thumbnail

Hi,

I want to create a thumbnail for a word,excel,powerpoint and pdf.
I checked the api and got the options to save them to an image file, I was wondering if I can also provide the width and height of the image to generate.

Thanks,
Saumil

Hi Saumil,

I am representing Aspose.Slides. I like to share that Aspose.Slides have two separate APIs for PPT and PPTX presentations currently but they are packaged together. The slide thumbnails for both PPT and PPTX slides can be generated. In case of PPT, the Slide.getThumbnail() allows to generate the slide thumbnail based on user defined dimensions and slide scale values. The link share before exhibits all possible types of getThumbnail() options. Please follow this documentation link for code snippet help to generate the slide thumbnails.

In case of PPTX, the only option avaialble for generating the slide thumbanil is based on scale of slide. Please visit this link to see SlideEx.getThumbnail() option in PPTX. There is no direct option to set the custom size for thumbnail in case of PPTX presently as in case of PPT. But there is a work around that can be used for getting the desired size thumbnail of slide in PPTX. The default slide size is 720 x 540. When SlideEx.getThumbnail(1.0f, 1.0f) parameter is used, it will generate the slide thumbnail with size 720 x540. So, if you intend to get the slide thumbnail of size 1200 x 800, you need to perform following small calculation on your end to achieve this.

PresentationEx pres=new PresentationEx("D:\\Aspose Data\\abc.pptx);
int desiredX=1200;
int desiredY=800;

float ScaleX=(float)(1.0/ps.getSlideSize().getSize().getWidth())*desiredX;
float ScaleY=(float)(1.0/ps.getSlideSize().getSize().getHeight())*desiredY;

for(int i=0;i<pres.getSlides().size ();i++)
{
image=pres.getSlides().get(iq).getThumbnail(ScaleX,ScaleY);
ImageIO.write(image,"jpeg", new File("Image_"+i+".jpg"));
}


Thanks and Regards,

Hi

Thank you for your interest in Aspose products. I am representative of Aspose.Words team. Using Aspose.Words, you can create thumbnails of Word document’s pages. Please follow the link for more information:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.saving.imagesaveoptions.html

To zoom the generated images, you can use Scale property:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.saving.imagesaveoptions.scale.html

Best regards,

Hi Saumil,

I’m sorry to inform you that that it is not feasible to specify the size of the converted images when converting PDF to images using Aspose.Pdf.Kit for Java. We have logged a new feature request as PDFKITJAVA-18151 in our issue tracking system to provide support for this feature. You’ll be updated when it is supported in future. We do provide this feature in the .NET version though.

We’re sorry for the inconvenience.
Regards,

Hi,

I am a representative of Aspose.Cells for Java team and would help you creating thumbnail for Excel worksheets. Please see the following sample Java program on how you can create a thumbnail of the generated image (using Sheet-to-Image feature provided by the component).

Sample code:

//…

import com.aspose.cells.*;*

import java.io.*;

import java.awt.image.*;*

import java.awt.;

import javax.imageio.*;

public class Thumbnail1

{

public static void main(String[] args) throws Exception

{

//Instantiate and open an Excel file

Workbook book = new Workbook(“e:\test\book1.xls”);

//Define ImageOrPrintOptions

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

//Set the vertical and horizontal resolution

imgOptions.setVerticalResolution(200);

imgOptions.setHorizontalResolution(200);

//Set the format type of the image

imgOptions.setImageFormat(ImageFormat.getJpeg());

//One page per sheet is enabled

imgOptions.setOnePagePerSheet(true);

//Get the first worksheet

Worksheet sheet = book.getWorksheets().get(0);

//Render the sheet with respect to specified image/print options

SheetRender sr = new SheetRender(sheet, imgOptions);

//Render the image for the sheet

sr.toImage(0, “mythumb.jpg”);

Image img = ImageIO.read(new File(“mythumb.jpg”)).getScaledInstance(100, 100, BufferedImage.SCALE_SMOOTH);

BufferedImage img1 = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);

img1.createGraphics().drawImage(ImageIO.read(new File(“mythumb.jpg”)).getScaledInstance(100, 100, Image.SCALE_SMOOTH),0,0,null);

ImageIO.write(img1, “jpg”, new File(“thumbnaul_out.jpg”));

}

}

Hope, this helps.

Thank you.

Thank you so much for your quick response.