Shrink a bloated .pptx file by 50–70% without touching a single slide, word, layout, animation, or embedded font.
This is a Claude Code Skill, but the underlying script is a plain Python CLI you can use standalone.
A .pptx is a ZIP archive. The slide markup (XML) is a few hundred KB at most; the bulk is almost always embedded media. This tool only touches media:
| Asset | Action |
|---|---|
Videos (.mp4) |
Re-encoded with ffmpeg, H.264, configurable CRF |
| JPEGs | Re-encoded at configurable quality, optionally downsampled to 1920px |
| PNGs (with real alpha) | Optimized in place, kept as PNG |
| PNGs (no alpha) — aggressive mode only | Converted to JPEG; [Content_Types].xml and all .rels references patched |
| Slide XML, animations, themes, charts, tables | Not touched |
Embedded fonts (ppt/fonts/*.fntdata) |
Not touched — removing them causes layout drift on machines without the same fonts |
Real result from a 262 MB presentation with 2 videos, 168 images and 13 embedded fonts:
Before : 262.0 MB
After : 81.0 MB (-69.1%)
Stats : Stats(jpeg=30, png_keep=35, png_to_jpg=123, videos=2, skipped=15, errors=0)
git clone https://github.com/ystyleb/pptx-compressor ~/.claude/skills/pptx-compressorThen in Claude Code, any mention of "compress PPT", "PPTX 太大", "shrink this deck" etc. will invoke the skill.
git clone https://github.com/ystyleb/pptx-compressor
cd pptx-compressor
pip install Pillow
# macOS
brew install ffmpeg
# Debian/Ubuntu
# sudo apt install ffmpeg
python3 scripts/compress_pptx.py path/to/deck.pptx- Python 3.9+
- Pillow —
pip install Pillow - ffmpeg on
PATH(skip with--skip-videoif the deck has no videos)
python3 scripts/compress_pptx.py INPUT.pptx [-o OUTPUT.pptx]
[--level {conservative,medium,aggressive}]
[--skip-video]
[--quiet]
| Level | JPEG q | Video CRF | Max edge | No-alpha PNG → JPG | Typical savings |
|---|---|---|---|---|---|
conservative |
85 | 24 | — | no | ~30% |
medium |
80 | 28 | 1920px | no | ~50% |
aggressive (default) |
80 | 28 | 1920px | yes | ~70% |
The default is aggressive because slide decks are almost always projected or viewed at ≤1080p, where a 4096px source photo is strictly waste. If you're printing or archiving originals, use conservative.
# Overwrite in place; original is saved to deck.bak.pptx alongside
python3 scripts/compress_pptx.py deck.pptx
# Keep original untouched, write to a new file
python3 scripts/compress_pptx.py deck.pptx -o deck.small.pptx
# I care about photo quality more than file size
python3 scripts/compress_pptx.py deck.pptx --level conservative
# Don't re-encode videos (I've already optimized them)
python3 scripts/compress_pptx.py deck.pptx --skip-videoIf anything looks wrong after compression:
mv deck.bak.pptx deck.pptx.pptx is just a ZIP archive. Every image and video reference inside slide XML goes through ppt/slides/_rels/slideN.xml.rels:
<Relationship Id="rId3" Target="../media/image42.png" .../>If you re-encode image42.png as a JPEG, you need to:
- Rename it to
image42.jpgon disk. - Update every
.relsfile that refers to it. - Make sure
[Content_Types].xmldeclares<Default Extension="jpg" ContentType="image/jpeg"/>.
Skip any of these and PowerPoint shows "some content could not be displayed" placeholders.
This tool does all three, and then runs a reference-integrity check before writing the output: every Target= in every .rels must resolve to a real file inside the archive, otherwise the script aborts without touching the original. It also runs a final sanity pass (unzip, parse key XMLs, open a sample image) on the output.
Things this tool does not do and is explicit about not doing:
- It does not remove embedded fonts, even though they're often the largest single remaining category. Removing fonts can make the deck look wrong on machines that don't have them installed. If you control the playback machine and want to strip fonts, do it by hand.
- It does not claim the output is "identical". Re-encoding is lossy. The honest framing is: visually indistinguishable in normal presentation use, slightly lower quality if you pixel-peep at 1:1.
- It does not modify
.ppt(legacy binary). Open it in PowerPoint/Keynote and "Save As .pptx" first.
MIT. See LICENSE.
Built with Claude Code. Issues and PRs welcome.