Compress images in PPTX files
Project description
compress-pptx
Compress a PPTX file, converting all PNG/TIFF images to lossy JPEGs.
What it does
When copy-pasting images to PowerPoint presentations, these sometimes get inserted as lossless versions, blowing up the size of the presentation.
This script takes all PNG or TIFF images part of the presentation which are larger than a given threshold (1 MiB by default), converts them to a lossy JPEG variant, and creates a new PPTX file.
PNGs containing transparency will be skipped to prevent graphics issues. ## Requirements
Python 3.5 or higher
ImageMagick’s magick, which calls convert and identify
Under Ubuntu, get ImageMagick via:
apt install imagemagick
Installation
Via pip:
pip3 install --user compress-pptx
Usage
Call compress_pptx and point it to a PPTX file. It’ll compress the images and output another compressed file next to it.
For more options, see the -h output:
compress_pptx [-h] [-o OUTPUT] [-s SIZE] [-q QUALITY] [-v] input positional arguments: input optional arguments: -h, --help show this help message and exit -o OUTPUT, --output OUTPUT Output file -s SIZE, --size SIZE Minimum size threshold in bytes. Also accepts the suffixes k/M/G or KiB/MiB/GiB -q QUALITY, --quality QUALITY JPEG output quality (0-100) -v, --verbose Show additional info
Bash Version
There’s an unmaintained Bash version under bash/compress-pptx.sh.
License
MIT License
Copyright (c) 2021 Werner Robitza
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Changelog
v0.1.1 (2021-02-08)
Better error handling; check for magick command.
Add badge to readme.
v0.1.0 (2021-02-07)
Fix README.
Add changelog.
Switch to python package.
Various updates, v0.2.
Add TODO notice.
Handle input errors.
Update instructions, add script.
Add script and README.
Initial commit.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for compress_pptx-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b772a8e689ae3dd5a8bcc2d33984c4f4d81e8010773ca8dfeffaf16a284d1bdb |
|
MD5 | d6c4c1f3bf81abd098105d81f95051fb |
|
BLAKE2b-256 | 7a807cd308450b1e5938ed33eb957507d274e78a1cef432172f9db4fdc123a7e |