In this tutorial, we will introduce how to convert every slide in a ppt or pptx file to image using python.
Preliminary
We will use python-pptx and python_pptx_interface.
We can install python-pptx as follows:
pip install python-pptx
We can find python_pptx_interface here. Download it to your project.
Convert ppt slide to images
Here is an example code.
from pptx_tools import utils # needs python-pptx-interface installed # you should use full paths, to make sure PowerPoint can handle the paths png_folder = r"D:\workspace-pytorch\00_paperwithcode\images" presentation_path = r"D:\workspace-pytorch\00_paperwithcode\1015.pptx" utils.save_pptx_as_png(png_folder, presentation_path, overwrite_folder=True)
Run this code, we will see:
If you get this error:Comptype module needed to save PNGs. You can see:
Fix Comptype module needed to save PNGs When Converting PPT to PNG