Python 3 Script to Compress Powerpoint (.PPTX) Slides File Size and Convert to JPG,PNG Images in Command Line Using compress-pptx Library

 

 

compress-pptx

PyPI version

Compress a PPTX or POTX file, converting all PNG/TIFF images to lossy JPEGs.

What it does

When copy-pasting images to PowerPoint presentations, these sometimes get inserted as lossless versions, blowing up the size of the presentation.

This script takes all PNG or TIFF images part of the presentation which are larger than a given threshold (1 MiB by default), converts them to a lossy JPEG variant, and creates a new PPTX file.

⚠️ This is not the same as compressing images with PowerPoint’s own functionality. You may still need to do this to reduce the size of your presentation!

PNGs containing transparency can be skipped to prevent graphics issues. Normally their transparent parts are replaced with white (although you can choose another color).

Requirements

  • Python 3.5 or higher
  • ImageMagick’s convert and identify

Under Ubuntu, get ImageMagick via:

Under macOS, install it with Homebrew:

Installation

Via pip:

Usage

Call compress-pptx and point it to a PPTX or POTX file. It’ll compress the images and output another compressed file next to it.

For more options, see the -h output:

 

 

 

 

 

https://github.com/slhck/compress-pptx

 

 

Leave a Reply