user12392864
user12392864

Reputation: 308

convert pptx into PNGs

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.

Upvotes: 0

Views: 6690

Answers (3)

gmmu8j
gmmu8j

Reputation: 111

To build on natter1's answer, two things that I had to do to get save_pptx_as_png to work on Windows:

  1. Install the comptypes library (i.e. pip install comtypes)
  2. Format my folder_to_save_pngs and pptx_filename paths with backslashes rather than the forward slashes common in Python coding. e.g. C:\users\me\documents\foo.pptx rather than C:/users/me/documents/foo.pptx

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."

Upvotes: 1

natter1
natter1

Reputation: 394

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.

Upvotes: 1

Mukesh Jha
Mukesh Jha

Reputation: 944

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.

Upvotes: 1

Related Questions