scholer / pptx-downsizer Goto Github PK
View Code? Open in Web Editor NEWPython tool for downsizing Microsoft PowerPoint presentations (pptx) files.
License: GNU General Public License v3.0
Python tool for downsizing Microsoft PowerPoint presentations (pptx) files.
License: GNU General Public License v3.0
Hi,
thank you for developing this tool, it really solves a pain point I have encountered before.
I have a suggestion of something that would be nice to have: list all media files by size, as a way to inform the user.
The reason I am asking this is that I often have video files included in presentations, and often they are the reason for presentations exploding in size. When content is mixed between images and movies, it would help me judge what I should aim at first.
Cheers!
Florian
@scholer I used pptx-downsizer package to compress the image in pptx file.
The order of the image are getting collapesd and mixed up.
Can you pleaase help with this issue.
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 python3
import argparse
import collections.abc # Python 3.10 workaround https://github.com/scanny/python-pptx/issues/762
from pptx import Presentation
parser = 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 = 0
prs = Presentation(args.filename)
for slide_layout in prs.slide_layouts:
if not slide_layout.used_by_slides:
print(f"Removing unused slide layout: {slide_layout.name}")
prs.slide_layouts.remove(slide_layout)
count += 1
if count == 0:
print("All slide layouts in use. Nothing to do.")
else:
prs.save(args.output)
I believe PIL doesn't support svg images which is why a pptx with an svg will fail. Probably better to skip the file if it's unsupported rather than die with an exception.
Traceback (most recent call last):
File "/home/chahu/.local/bin/pptx-downsizer", line 8, in <module>
sys.exit(cli())
File "/home/chahu/.local/lib/python3.10/site-packages/pptx_downsizer/pptx_downsizer.py", line 466, in cli
downsize_pptx_images(**params)
File "/home/chahu/.local/lib/python3.10/site-packages/pptx_downsizer/pptx_downsizer.py", line 147, in downsize_pptx_images
img = Image.open(imgfn)
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 3008, in open
raise UnidentifiedImageError(
PIL.UnidentifiedImageError: cannot identify image file '/tmp/tmpwp8xphkm/ppt/media/image16.svg'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.