This quick guide explains how to compress PowerPoint presentation size using Python. You will get details to set up the IDE for using the library, a set of step-by-step instructions, and sample code to minimize PowerPoint file size using Python without effecting the presentation such as GIF animation in it, if any. More APIs will also be introduced to enhance the given sample code for further reduction in the PPT/PPTX file size.
Steps to Shrink PowerPoint File Size using Python
- Set the IDE to use Aspose.Slides for Python via .NET to compress a presentation
- Set up the input/output file names, target image resolution, and the JPEG quality
- Load the source presentation and collect all the normal, layout and master slides in a list
- Iterate through the collection of pictures on each slide and lower their resolution
- Covert each non-JPEG image to JPEG and keep it if its size is smaller than the original image
- Delete all the unused master and layout slides from the presentation
- Shrink the embedded fonts by removing unused characters in the slide
- Save the resultant presentation as PPT or PPTX as per your requirements
These steps summarize how to reduce PowerPoint file size using Python. Load the presentation, collect all types of slides in it including normal, layout, and master, iterate through all the pictures on the presentation, and lower their resolution. Covert each non-JPEG image to JPEG with a low resolution, delete all the unused layout and master slides, remove unused characters from the embedded bots, and save the resultant presentation.
Code for Reducing PowerPoint File Size using Python
This code demonstrates how to compress a PowerPoint file using Python. For further reduction in the size of the presentation, you can compress pictures used as fills, remove cropped-away image data, and raise the save compression to the maximum ZIP level. You can also turn off thumbnail generation on save, remove the unused fonts completely, strip embedded binary content at load time such as VBA macros, OLE object data, and ActiveX data, if any.
This code shows how to reduce the prevention size. To add SmartArt graphics in a presentation, refer to the article Add SmartArt Graphics in PowerPoint using Python.