# compress-pptx
[![PyPI version](https://img.shields.io/pypi/v/compress-pptx.svg)](https://pypi.org/project/compress-pptx)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
Compress a PPTX or POTX 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.
:warning: This is not the same as compressing images with PowerPoint's own functionality. You may still need to do this to reduce the size of your presentation!
PNGs containing transparency can be skipped to prevent graphics issues. Normally their transparent parts are replaced with white (although you can choose another color).
## Requirements
- Operating system: macOS or Linux
- Note: Under Linux, you need LibreOffice installed to convert embedded EMF files
- Python 3.8 or higher
- ImageMagick's `magick` commands (`magick convert` and `magick identify`)
- Optionally: `ffmpeg` for media files, and
Under Ubuntu, get ImageMagick via:
```
apt install imagemagick
```
Under macOS, install it with [Homebrew](https://brew.sh):
```
brew install imagemagick
```
For ffmpeg, use the static builds from [ffmpeg.org](https://ffmpeg.org/downloads.html).
## Installation
Via pip:
```
pip3 install --user compress-pptx
```
## Usage
Call `compress-pptx` and point it to a PPTX or POTX file. It'll compress the images and output another compressed file next to it.
For more options, see the `-h` output:
```
usage: compress-pptx [-h] [-o OUTPUT] [-s SIZE] [-q QUALITY] [-t TRANSPARENCY]
[-k] [-v] [-f] [-m] [-j] [-l] [--num-cpus NUM_CPUS]
input
positional arguments:
input
options:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
Output file (default: None)
-s SIZE, --size SIZE Minimum size threshold in bytes. Also accepts the
suffixes k/M/G or KiB/MiB/GiB (default: 1MiB)
-q QUALITY, --quality QUALITY
JPEG output quality (0-100) (default: 85)
-t TRANSPARENCY, --transparency TRANSPARENCY
Replace transparency with color (default: white)
-k, --skip-transparent-images
Skip converting transparent images at all (default:
False)
-v, --verbose Show additional info (default: False)
-f, --force Force overwriting output file (default: False)
-m, --compress-media Compress other media types such as audio and video
(requires ffmpeg) (default: False)
-j, --recompress-jpeg
Recompress jpeg images (default: False)
-l, --use-libreoffice
Use LibreOffice to compress EMF files (only way to
compress EMF files under Linux) (default: False)
--num-cpus NUM_CPUS Number of CPUs to use (default: all available CPUs)
```
## Bash Version
There's an unmaintained Bash version under `bash/compress-pptx.sh`.
## Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/caydey"><img src="https://avatars.githubusercontent.com/u/63204672?v=4?s=100" width="100px;" alt="caydey"/><br /><sub><b>caydey</b></sub></a><br /><a href="https://github.com/slhck/compress-pptx/commits?author=caydey" title="Code">💻</a></td>
</tr>
</tbody>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
## License
MIT License
Copyright (c) 2021-2023 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.8.3 (2023-10-02)
* Migrate to magick commands.
## v0.8.2 (2023-10-02)
* Add CLI option for num_cpus.
## v0.8.1 (2023-10-02)
* Formatting and fix path handling.
## v0.8.0 (2023-03-13)
* Bump requirement to python 3.8.
* Docs: add @caydey as a contributor.
* Update README and minor code changes.
* Added '-l' to compress emf files using libreoffice.
* Fixed bug for when file compression fails.
* Fixed bug with clashing variable names.
* Refractored "image" to "file"
* Media file compression and recompress jpeg files.
## v0.7.2 (2023-01-30)
* Remove manifest.in.
## v0.7.1 (2022-08-02)
* Update python requirements.
## v0.7.0 (2022-08-02)
* Update python requirements.
## v0.6.0 (2021-10-28)
* Add feature to skip transparent images completely, add EMF.
## v0.5.0 (2021-08-06)
* Allow POTX files, fixes #4.
* Fallback to 'convert' and 'identify', fixes #3.
## v0.4.0 (2021-05-25)
* Add handling of transparency and TIFFs.
## v0.3.0 (2021-05-14)
* Auto-formatting.
* Add -f/--force parameter.
* Update gitignore.
## v0.2.1 (2021-03-29)
* Add defaults to CLI options.
* Update badge link.
## v0.2.0 (2021-03-10)
* Change executable name for harmonization purposes.
## v0.1.3 (2021-03-10)
* Improve setup.py.
* Remove release script.
## v0.1.2 (2021-03-06)
* Format setup.py and switch to markdown.
* Add warning.
* Update badge URL.
## 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/slhck/compress-pptx",
"name": "compress-pptx",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Werner Robitza",
"author_email": "werner.robitza@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/39/24/89e7480213402ad45043d1ef05b1afe10acb8d0b0d966ea7ffb978970919/compress_pptx-0.8.3.tar.gz",
"platform": null,
"description": "# compress-pptx\n\n[![PyPI version](https://img.shields.io/pypi/v/compress-pptx.svg)](https://pypi.org/project/compress-pptx)\n\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\nCompress a PPTX or POTX file, converting all PNG/TIFF images to lossy JPEGs.\n\n## What it does\n\nWhen copy-pasting images to PowerPoint presentations, these sometimes get inserted as lossless versions, blowing up the size of the presentation.\n\nThis 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.\n\n:warning: This is not the same as compressing images with PowerPoint's own functionality. You may still need to do this to reduce the size of your presentation!\n\nPNGs containing transparency can be skipped to prevent graphics issues. Normally their transparent parts are replaced with white (although you can choose another color).\n## Requirements\n\n- Operating system: macOS or Linux\n - Note: Under Linux, you need LibreOffice installed to convert embedded EMF files\n- Python 3.8 or higher\n- ImageMagick's `magick` commands (`magick convert` and `magick identify`)\n- Optionally: `ffmpeg` for media files, and\n\nUnder Ubuntu, get ImageMagick via:\n\n```\napt install imagemagick\n```\n\nUnder macOS, install it with [Homebrew](https://brew.sh):\n\n```\nbrew install imagemagick\n```\n\nFor ffmpeg, use the static builds from [ffmpeg.org](https://ffmpeg.org/downloads.html).\n\n## Installation\n\nVia pip:\n\n```\npip3 install --user compress-pptx\n```\n\n## Usage\n\nCall `compress-pptx` and point it to a PPTX or POTX file. It'll compress the images and output another compressed file next to it.\n\nFor more options, see the `-h` output:\n\n```\nusage: compress-pptx [-h] [-o OUTPUT] [-s SIZE] [-q QUALITY] [-t TRANSPARENCY]\n [-k] [-v] [-f] [-m] [-j] [-l] [--num-cpus NUM_CPUS]\n input\n\npositional arguments:\n input\n\noptions:\n -h, --help show this help message and exit\n -o OUTPUT, --output OUTPUT\n Output file (default: None)\n -s SIZE, --size SIZE Minimum size threshold in bytes. Also accepts the\n suffixes k/M/G or KiB/MiB/GiB (default: 1MiB)\n -q QUALITY, --quality QUALITY\n JPEG output quality (0-100) (default: 85)\n -t TRANSPARENCY, --transparency TRANSPARENCY\n Replace transparency with color (default: white)\n -k, --skip-transparent-images\n Skip converting transparent images at all (default:\n False)\n -v, --verbose Show additional info (default: False)\n -f, --force Force overwriting output file (default: False)\n -m, --compress-media Compress other media types such as audio and video\n (requires ffmpeg) (default: False)\n -j, --recompress-jpeg\n Recompress jpeg images (default: False)\n -l, --use-libreoffice\n Use LibreOffice to compress EMF files (only way to\n compress EMF files under Linux) (default: False)\n --num-cpus NUM_CPUS Number of CPUs to use (default: all available CPUs)\n```\n\n## Bash Version\n\nThere's an unmaintained Bash version under `bash/compress-pptx.sh`.\n\n## Contributors\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n <tbody>\n <tr>\n <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/caydey\"><img src=\"https://avatars.githubusercontent.com/u/63204672?v=4?s=100\" width=\"100px;\" alt=\"caydey\"/><br /><sub><b>caydey</b></sub></a><br /><a href=\"https://github.com/slhck/compress-pptx/commits?author=caydey\" title=\"Code\">\ud83d\udcbb</a></td>\n </tr>\n </tbody>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\n## License\n\nMIT License\n\nCopyright (c) 2021-2023 Werner Robitza\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\n# Changelog\n\n\n## v0.8.3 (2023-10-02)\n\n* Migrate to magick commands.\n\n\n## v0.8.2 (2023-10-02)\n\n* Add CLI option for num_cpus.\n\n\n## v0.8.1 (2023-10-02)\n\n* Formatting and fix path handling.\n\n\n## v0.8.0 (2023-03-13)\n\n* Bump requirement to python 3.8.\n\n* Docs: add @caydey as a contributor.\n\n* Update README and minor code changes.\n\n* Added '-l' to compress emf files using libreoffice.\n\n* Fixed bug for when file compression fails.\n\n* Fixed bug with clashing variable names.\n\n* Refractored \"image\" to \"file\"\n\n* Media file compression and recompress jpeg files.\n\n\n## v0.7.2 (2023-01-30)\n\n* Remove manifest.in.\n\n\n## v0.7.1 (2022-08-02)\n\n* Update python requirements.\n\n\n## v0.7.0 (2022-08-02)\n\n* Update python requirements.\n\n\n## v0.6.0 (2021-10-28)\n\n* Add feature to skip transparent images completely, add EMF.\n\n\n## v0.5.0 (2021-08-06)\n\n* Allow POTX files, fixes #4.\n\n* Fallback to 'convert' and 'identify', fixes #3.\n\n\n## v0.4.0 (2021-05-25)\n\n* Add handling of transparency and TIFFs.\n\n\n## v0.3.0 (2021-05-14)\n\n* Auto-formatting.\n\n* Add -f/--force parameter.\n\n* Update gitignore.\n\n\n## v0.2.1 (2021-03-29)\n\n* Add defaults to CLI options.\n\n* Update badge link.\n\n\n## v0.2.0 (2021-03-10)\n\n* Change executable name for harmonization purposes.\n\n\n## v0.1.3 (2021-03-10)\n\n* Improve setup.py.\n\n* Remove release script.\n\n\n## v0.1.2 (2021-03-06)\n\n* Format setup.py and switch to markdown.\n\n* Add warning.\n\n* Update badge URL.\n\n\n## v0.1.1 (2021-02-08)\n\n* Better error handling; check for magick command.\n\n* Add badge to readme.\n\n\n## v0.1.0 (2021-02-07)\n\n* Fix README.\n\n* Add changelog.\n\n* Switch to python package.\n\n* Various updates, v0.2.\n\n* Add TODO notice.\n\n* Handle input errors.\n\n* Update instructions, add script.\n\n* Add script and README.\n\n* Initial commit.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Compress images in PPTX files",
"version": "0.8.3",
"project_urls": {
"Homepage": "https://github.com/slhck/compress-pptx"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7664b6853f6445a6f1194522fc58650a603bcf0b1168916b86efabd5930205f2",
"md5": "58ffd63347b404b78d68a81844964fab",
"sha256": "50976bd437f0353c15ade35350d1ee1560c5d936233d78b0276edf5849bb2ffb"
},
"downloads": -1,
"filename": "compress_pptx-0.8.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "58ffd63347b404b78d68a81844964fab",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 11652,
"upload_time": "2023-10-02T19:15:27",
"upload_time_iso_8601": "2023-10-02T19:15:27.013772Z",
"url": "https://files.pythonhosted.org/packages/76/64/b6853f6445a6f1194522fc58650a603bcf0b1168916b86efabd5930205f2/compress_pptx-0.8.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "392489e7480213402ad45043d1ef05b1afe10acb8d0b0d966ea7ffb978970919",
"md5": "b03d1fc0fad905a76c2d00a914f6f2cc",
"sha256": "c8763d6551de378e5774aa2da1f2ece229e9dfdc4e845a240c4c20a36ab6c33b"
},
"downloads": -1,
"filename": "compress_pptx-0.8.3.tar.gz",
"has_sig": false,
"md5_digest": "b03d1fc0fad905a76c2d00a914f6f2cc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 3272030,
"upload_time": "2023-10-02T19:15:29",
"upload_time_iso_8601": "2023-10-02T19:15:29.731932Z",
"url": "https://files.pythonhosted.org/packages/39/24/89e7480213402ad45043d1ef05b1afe10acb8d0b0d966ea7ffb978970919/compress_pptx-0.8.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-02 19:15:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "slhck",
"github_project": "compress-pptx",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "tqdm",
"specs": []
}
],
"lcname": "compress-pptx"
}