python-pptx is not the right tool for this task, as it does not interact with PowerPoint at all (it works without an installed version of PowerPoint). If you have PowerPoint installed on your system you could use e.g. comtypes module to control it from python. An example how to do it could be found in python-pptx-interface module:
from comtypes.client import Constants, CreateObject
# ...
def save_pptx_as_png(png_foldername: str, pptx_filename: str, overwrite_folder: bool = False):
if os.path.isdir(png_foldername) and not overwrite_folder:
print(f"Folder {png_foldername} already exists. "
f"Set overwrite_folder=True, if you want to overwrite folder content.")
return
powerpoint = CreateObject("Powerpoint.Application")
pp_constants = Constants(powerpoint)
pres = powerpoint.Presentations.Open(pptx_filename)
pres.SaveAs(png_foldername, pp_constants.ppSaveAsPNG)
pres.close()
if powerpoint.Presentations.Count == 0: # only close, when no other Presentations are open!
powerpoint.quit()
This should give you an idea, how to write your own save_as_png function.
Or you use python-pptx-interface directly:
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 = ...
pptx_file = ...
utils.save_pptx_as_png(png_folder, pptx_file) # additional optional parameter overwrite_folder