This quick guide explains how to compress the size of a PowerPoint presentation using Python. You will get details to configure the IDE for using the library, a set of step‑by‑step instructions and sample code to reduce the size of a PowerPoint file using Python without affecting the presentation, such as any GIF animations inside it. Additional APIs will also be introduced to improve the provided sample code and further reduce the size of the PPT/PPTX files.
Passaggi per ridurre le dimensioni del file PowerPoint con Python
- Set the IDE to use Aspose.Slides for Python via .NET to compress a presentation.
- Configure the input/output file names, the target image resolution, and the JPEG quality.
- Load the source presentation and collect all the normal, layout, and master slides into a list.
- Iterate through the collection of pictures on each slide and reduce their resolution.
- Converti ogni immagine non JPEG in JPEG e mantienila se la sua dimensione è inferiore a quella dell’immagine originale
- Delete all unused master slides and layouts from the presentation.
- Reduce embedded fonts by removing unused characters on the slide.
- Salva la presentazione risultante come PPT o PPTX secondo le tue esigenze
Questi passaggi riassumono come ridurre le dimensioni di un file PowerPoint usando Python. Load the presentation, gather all types of slides in it—including normal, layout, and master slides—iterate over all images in the presentation, and reduce their resolution. Converte ogni immagine non JPEG in JPEG a bassa risoluzione, elimina tutte le diapositive di layout e master inutilizzate, rimuove i caratteri inutilizzati dai bot incorporati e salva la presentazione risultante.
Code to reduce the size of a PowerPoint file using Python
This code demonstrates how to compress a PowerPoint file using Python. Per un’ulteriore riduzione delle dimensioni della presentazione, è possibile comprimere le immagini usate come riempimenti, rimuovere i dati delle immagini ritagliate e aumentare la compressione di salvataggio al livello massimo ZIP. It is also possible to disable thumbnail generation on save, completely remove unused fonts, and delete embedded binary content at load time, such as VBA macros, OLE object data, and ActiveX data, if present.
Questo codice mostra come ridurre le dimensioni della prevenzione. To add SmartArt graphics to a presentation, see the article Add SmartArt graphics in PowerPoint using Python.