You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a script that depends on python-pptx that removes unused slide layouts. This can amount to a huge size reduction in some cases. Would be cool if this functionality was included in this project.
See below standalone python script to get an idea:
#!/usr/bin/env python3importargparseimportcollections.abc# Python 3.10 workaround https://github.com/scanny/python-pptx/issues/762frompptximportPresentationparser=argparse.ArgumentParser(description="Remove unused pptx slide layouts")
parser.add_argument("filename")
parser.add_argument("-o", "--output", required=True, help="Where to save the output")
args=parser.parse_args()
count=0prs=Presentation(args.filename)
forslide_layoutinprs.slide_layouts:
ifnotslide_layout.used_by_slides:
print(f"Removing unused slide layout: {slide_layout.name}")
prs.slide_layouts.remove(slide_layout)
count+=1ifcount==0:
print("All slide layouts in use. Nothing to do.")
else:
prs.save(args.output)
The text was updated successfully, but these errors were encountered:
I have a script that depends on python-pptx that removes unused slide layouts. This can amount to a huge size reduction in some cases. Would be cool if this functionality was included in this project.
See below standalone python script to get an idea:
The text was updated successfully, but these errors were encountered: