Thumbnails are small-sized images that make it easier to look at or scroll through the list of images. They are also used in MS PowerPoint to list the slides and navigate in a PPT. While creating a PPT viewer application, you may need to generate thumbnail images for the slides. To accomplish that, this article covers how to create thumbnails for PPTX or PPT slides programmatically in Python.
- Python Library to Create Thumbnails for PPT Slides
- Create Thumbnails for PPTX/PPT Slides
- Create Thumbnails with User-Defined Dimensions
Python Library to Create Thumbnails for PPT Slides
To create thumbnails for slides in PPTX or PPT presentations, we will use Aspose.Slides for Python via .NET. The library provides a bunch of features to create and manipulate PowerPoint presentations. Moreover, it lets you convert the presentations to other formats. You can install the library in your applications from PyPI using the following command.
> pip install aspose.slides
Create Thumbnails for PPT Slides in Python
The following are the steps to create thumbnails for a presentation in Python.
- First, load the presentation file using Presentation class.
- Loop through each ISlide in Presentation.slides collection.
- Create thumbnail of the each slide using ISlide.get_thumbnail(scale_x, scale_y) method and get the reference of thumbnail into a Bitmap object.
- Finally, save the thumbnail into your desired image format using Bitmap.save(String, ImageFormat) method.
The following code sample shows how to create thumbnails for slides in a PPTX presentation in Python.
Create PPT Thumbnails with Custom Dimensions
Often, you may need to create thumbnails of customized dimensions. This can be achieved using Presentation.slide_size.size.width and Presentation.slide_size.size.height properties. The following are the steps to create thumbnails of custom dimensions.
- First, create an instance of the Presentation class to load the presentation.
- Then, specify desired values of width and height.
- Get scaled values of the X and Y.
- Loop through each ISlide in Presentation.slides collection.
- Generate thumbnail of the each slide using ISlide.get_thumbnail(X, Y) method and get the reference of thumbnail into a Bitmap object.
- Finally, save the thumbnail into your desired image format using Bitmap.save(string, ImageFormat) method.
The following code sample shows how to create thumbnails of a PPTX with customized dimensions.
Get a Free License
You can use Aspose.Slides for Python via .NET without evaluation limitations by requesting a temporary license.
Conclusion
In this article, you have learned how to create thumbnails of PPT slides in Python. Moreover, you have seen how to use custom dimensions to scale the PPT thumbnail images. In addition, you can visit the documentation to explore other features of Aspose.Slides for Python. Also, you can let us know about your queries via our forum.