matplotlib-lossless-webp
A tiny Python package that forces lossless compression in matplotlib when saving WebP images.
Otherwise, matplotlib's .webp exports are somewhat low quality unless you set specific PIL parameters.
In this way, you can use .webp as a smaller, drop-in replacement for .png while maintaining perfect quality.
Installation
This project is on PyPI and can be installed with
pip install matplotlib-lossless-webp
Usage
Importing the package will force all future savefig() calls to be lossless when the filename ends with .webp.
import matplotlib.pyplot as plt
import matplotlib_lossless_webp # noqa
plt.plot([1, 2, 3], [4, 5, 6])
plt.savefig('test.webp') # automatically saves as lossless / high quality
Why?
This is mostly for convenience, but scientific figures should normally be lossless, so this is a reasonable default!
Matplotlib is a bit strange for .webp files in that you can't just pass something like savefig(..., quality=100)
or savefig(..., lossless=True).
The (allegedly) intended invocation is to pass the lossless parameter through to PIL with
savefig(..., pil_kwargs={'lossless': True}), but that is cumbersome to add repeatedly.
If this needs to be disabled on a rare, case-by-case basis, this package will not override explicit usage like
savefig(..., pil_kwargs={'lossless': False}).
Metadata
Release files for matplotlib-lossless-webp 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| matplotlib_lossless_webp-1.1.1.tar.gz | 3.6 kB | Without provenance | Details for matplotlib_lossless_webp-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| matplotlib_lossless_webp-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for matplotlib_lossless_webp-1.1.1-py3-none-any.whl |
Total release size: 7.1 kB
Release files / matplotlib_lossless_webp-1.1.1.tar.gz
| Download URL | matplotlib_lossless_webp-1.1.1.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57364e2c1e2b3d3a5b8323078a6ddb6f3439ee1bc48b534301aac4e9e2bd5b31
|
|
BLAKE2b-256 checksum How to use checksums |
b33fea22ce2135ae439e3475f90944ad5a8446f21b5e313cca52f92008d6ff13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / matplotlib_lossless_webp-1.1.1-py3-none-any.whl
| Download URL | matplotlib_lossless_webp-1.1.1-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3a1b86c9ba24651a69e5c298f29df697d450bdd3f0619184c2791126d16fb6c
|
|
BLAKE2b-256 checksum How to use checksums |
f7e9bdb74643229edb2a24e28694c24d1f5cc1c2ee137b7b007da61fbeef273f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for matplotlib-lossless-webp 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.