Search code examples
pythonpowerpoint

Convert PPT to image with high resolution


Here is my code. A 429KB ppt file, using the following code to generate a 161KB(resolution:661*1181) png image, but I want the photo as the window background full screen. The resolution of 161KB is too low. How to generate high-definition versions in the Win10/Win7 environment. Thank you very much to those who answered.

import win32com.client
import sys
def ppt2png(ppt_path, output_filename):
    if os.path.exists(ppt_path):
        ppt_app = win32com.client.Dispatch('PowerPoint.Application')
        ppt = ppt_app.Presentations.Open(ppt_path)
        ppt.SaveAs(output_filename, 17)
        ppt_app.Quit()

May I need to convert the PowerPoint to PDF and then to image? I don't know. And I know that in ppt.SaveAs(), 17 is JPG, 18 is PNG, and 19 is BMP. However, although the images in BMP format are clearer, they still blur when enlarged due to insufficient resolution


Solution

  • I'm way out of my depth here, but I found the Presentation.Export method that might do what you need.

    Untested:

            ppt.Export(output_filename, 'png', 1920, 1080)
    

    The last two arguments determine the width and height in pixels of each exported slide.