Giter VIP home page Giter VIP logo

pptx-downsizer's Issues

suggestion for improvement: list media files sorted by size

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

Suggestion: Remove unused slide layouts

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)

SVG Images break

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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.