Is there a way of converting a pptx
file into png
files for each slide using Python?
I was thinking of converting pptx into pdf and then converting each pages into png but not sure if it is the optimal way.
Is there a way of converting a pptx
file into png
files for each slide using Python?
I was thinking of converting pptx into pdf and then converting each pages into png but not sure if it is the optimal way.
It's possible on windows using comtypes library. But same cannot be said for unix distributions because comtypes isn't supported in unix. For windows,if you couldn't figure it out:
https://gist.github.com/littmus/6496277
There is also python-pptx library but it doesn't have privilege for allowing to take Screenshot (Correct me if I am wrong.) In the meanwhile, this is really interesting question according to me, since there are many threads for the same, if you get it please post the answer over here.
To build on natter1's answer, two things that I had to do to get save_pptx_as_png to work on Windows:
If you don't do this, you may run into errors such as "Comptype module needed to save PNGs" or COMError "The system cannot find the path specified."
You could also use python-pptx-interface - it has something similar to what Mukesh linked as built in function:
from pptx_tools.utils import save_pptx_as_png
# use full path for pptx_filename
save_pptx_as_png(folder_to_save_pngs, pptx_filename, overwrite_folder=True)
overwrite_folder=True is needed, if the folder already exists. In that case, PNGs might be overwritten.