Skip to content

Instantly share code, notes, and snippets.

@discentem
Created October 30, 2016 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save discentem/c2c07adb93e95f3e1e61a75b26a39a62 to your computer and use it in GitHub Desktop.
Save discentem/c2c07adb93e95f3e1e61a75b26a39a62 to your computer and use it in GitHub Desktop.
import os
import sys
from pptx import Presentation
from pptx.util import Inches
def get_pictures(full_path):
return [f for f in os.listdir(full_path) if f.endswith('.jpg')]
def place_pics_on_sep_slides(directory):
prs = Presentation()
blank_slide_layout = prs.slide_layouts[6]
pictures = get_pictures(directory)
print(pictures)
for pic in pictures:
slide = prs.slides.add_slide(blank_slide_layout)
left = top = Inches(1)
height = Inches(5.5)
pic = slide.shapes.add_picture(pic, left, top, height=height)
prs.save('test.pptx')
place_pics_on_sep_slides(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment