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

Free Support Forum - aspose.com

How to set width and height in pixels

In this below code i am setting thumbnail image pixel size as 395 x 254, but once it's created the thumbnail image the size looks different 527 x 339.

Aspose.Words.Document doc = new Aspose.Words.Document(docStream);

// Render first page of Word document to an image stream
Aspose.Words.Saving.ImageSaveOptions options = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Png);
options.PageIndex = 0;
options.PageCount = 1;

MemoryStream imgStream = new MemoryStream();
doc.Save(imgStream, options);

// Insert the image stream into a temporary Document instance.
Aspose.Words.Document temp = new Aspose.Words.Document();
DocumentBuilder builder = new DocumentBuilder(temp);
Aspose.Words.Drawing.Shape img = builder.InsertImage(imgStream);

// Resize the image as per your needs
img.Width = 395;
img.Height = 254;

// Save the individual image to disk using ShapeRenderer class
ShapeRenderer renderer = img.GetShapeRenderer();
MemoryStream outStream = new MemoryStream();

renderer.Save(outStream, new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Png));
bytes = outStream.GetBuffer();
return bytes;

Hi Arul,

The reason is that you are setting the size in points and if you convert it to pixels, these values are correct. You can use the following code to set the size in pixels.

// Resize the image as per your needs

img.Width = 395 * 72 / 96;

img.Height = 254 * 72 / 96;<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

Best Regards,