Create Shape Thumbnails

Aspose.Slides for .NET is used to create presentation files where each page is a slides. These slides can be viewed by opening the presentation files using Microsoft PowerPoint. But sometimes, developers may need to view the images of the shapes separately in an image viewer. In such cases, Aspose.Slides for .NET helps you generate thumbnail images of the slide shapes. How to use this feature is described in this article. This article explains how to generate slide thumbnails in different ways:

  • Generating a shape thumbnail inside a slide.
  • Generating a shape thumbnail for a slide shape with user defined dimensions.
  • Generating a shape thumbnail in the bounds of a shape’s appearance.
  • Generating a thumbnail of SmartArt child node.

Generate Shape Thumbnail from Slide

To generate a shape thumbnail from any slide using Aspose.Slides for .NET:

  1. Create an instance of the Presentation class.
  2. Obtain the reference of any slide using its ID or index.
  3. Get the shape thumbnail image of the referenced slide on default scale.
  4. Save the thumbnail image to any desired image format.

The example below generating shape thumbnail.

using (Presentation presentation = new Presentation("HelloWorld.pptx"))
{
    IShape shape = presentation.Slides[0].Shapes[0];
    using (IImage image = shape.GetImage())
    {
        image.Save("Shape_thumbnail_out.png", ImageFormat.Png);
    }
}

Generate User Defined Scaling Factor Thumbnail

To generate the shape thumbnail of any slide shape using Aspose.Slides for .NET:

  1. Create an instance of the Presentation class.
  2. Obtain the reference of any slide using its ID or index.
  3. Get the thumbnail image of the referenced slide with shape bounds.
  4. Save the thumbnail image in any desired image format.

The example below generate a thumbnail with generating a thumbnail with user defined scaling factor.

ShapeThumbnailBounds bounds = ShapeThumbnailBounds.Shape;
float scale = 1; // Scaling along X and Y axes.

using (Presentation presentation = new Presentation("HelloWorld.pptx"))
{
    IShape shape = presentation.Slides[0].Shapes[0];
    using (IImage image = shape.GetImage(bounds, scale, scale))
    {
        image.Save("Scaling Factor Thumbnail_out.png", ImageFormat.Png);
    }
}

Create Bounds Shape’s Appearance Thumbnail

This method for creating thumbnails of shapes allows developers to generate a thumbnail in the bounds of the shape’s appearance. It takes into account all the shape effects. The generated shape thumbnail is restricted by the slide bounds. To generate a thumbnail of any slide shape in bound of its appearance, use following sample code:

  1. Create an instance of the Presentation class.
  2. Obtain the reference of any slide using its ID or index.
  3. Get the thumbnail image of the referenced slide with shape bounds as appearance.
  4. Save the thumbnail image in any desired image format.

The example below create a thumbnail with generating a thumbnail with user defined scaling factor.

ShapeThumbnailBounds bounds = ShapeThumbnailBounds.Appearance;
float scale = 1; // Scaling along X and Y axes.

using (Presentation presentation = new Presentation("HelloWorld.pptx"))
{
    IShape shape = presentation.Slides[0].Shapes[0];
    using (IImage image = shape.GetImage(bounds, scale, scale))
    {
        image.Save("Shape_thumbnail_Bound_Shape_out.png", ImageFormat.Png);
    }
}

FAQ

What image formats can be used when saving shape thumbnails?

PNG, JPEG, BMP, GIF, TIFF, and others. Shapes can also be exported as vector SVG by saving the shape’s content as SVG.

What is the difference between Shape and Appearance bounds when rendering a thumbnail?

Shape uses the shape’s geometry; Appearance takes visual effects (shadows, glows, etc.) into account.

What happens if a shape is marked as hidden? Will it still render as a thumbnail?

A hidden shape remains part of the model and can be rendered; the hidden flag affects slideshow display but does not prevent generating the shape’s image.

Are group shapes, charts, SmartArt, and other complex objects supported?

Yes. Any object represented as Shape (including GroupShape, Chart, and SmartArt) can be saved as a thumbnail or as SVG.

Do system-installed fonts affect the quality of thumbnails for text shapes?

Yes. You should provide the required fonts (or configure font substitutions) to avoid unwanted fallbacks and text reflow.