Add oxipng to pre-commit#29925
Conversation
|
And it seems |
|
The compressed images cause a single failure due to a warning: |
|
Thanks for giving it a try and sorry for the unexpected hassle. I use it in a GitLab project and since the pre-commit CI doesn't support that, I have to run it on the diff from the latest main (set in the script), so not sure if it runs on all files, but it is a reasonable guess I would assume. A small caveat that is worthwhile to consider is that if the compression improves, it will fail the tests. I wanted to have some sort of threshold, but the developers didn't see a need to support that (but suggested that one scripts it). (Edit: one may not want to commit a new image, just because the new compression removed 4 bytes...) But, good thing, size decreases. Just a bit boring if one will need to re-commit lots of compressed images... |
|
precommit was moved to GitHub Actions in #30045, so maybe that'll be a bit beefier and not timeout. |
|
Current status is that after the font overhaul, 383 images need an update to be compressed by oxipng. Possibly what we could do is pass |
Now it's down to 358, which is still a lot, so I've kept a PR-only check. |

PR summary
@oscargus suggested oxipng in #29816.
I went with the hook suggestion of
-o 4compression (though their normal default is 2), though maybe we want to up it to the max, since it shouldn't happen very often. I did not enable metadata stripping (as suggested) since knowing what version of Matplotlib was used for the plot might be useful. I also didn't add alpha channel optmization, as they say it is technically lossy.PR checklist