-
Notifications
You must be signed in to change notification settings - Fork 1.2k
pre-commit: add oxipng a lossless PNG compression optimizer #11065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
"Lossless compression is a data compression technique where the original data can be perfectly reconstructed from the compressed data. In essence, no information is lost during compression and decompression, making it ideal for situations where data integrity is critical" https://en.wikipedia.org/wiki/Lossless_compression https://github.com/oxipng/oxipng https://github.com/oxipng/oxipng?tab=readme-ov-file#git-integration-via-pre-commit Ran pre-commit here locally and it compressed the images on first run. So we have less data for some images with the same quality. Less data means less to download etc and saves bandwidth.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11065 +/- ##
=========================================
Coverage 17.56% 17.56%
Complexity 15533 15533
=========================================
Files 5909 5909
Lines 529013 529013
Branches 64605 64605
=========================================
Hits 92912 92912
- Misses 425652 425653 +1
+ Partials 10449 10448 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
looks good @jbampton , but how would enforcing this with github actions work? Will it refuse not optimised pictures or automatically compress them? |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds oxipng, a lossless PNG compression optimizer, to the pre-commit configuration to automatically optimize PNG images during the commit process. The addition helps reduce file sizes while maintaining image quality, which can improve bandwidth usage and download times.
Key changes:
- Adds oxipng hook to pre-commit configuration with optimization level 4 and safe stripping options
- Enables automatic PNG compression as part of the development workflow
DaanHoogland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm , please see my question @jbampton .
From the official site: https://pre-commit.com/ "Git hook scripts are useful for identifying simple issues before submission to code review. We run our hooks on every commit to automatically point out issues in code such as missing semicolons, trailing whitespace, and debug statements. By pointing these issues out before code review, this allows a code reviewer to focus on the architecture of a change while not wasting time with trivial style nitpicks." So pre-commit is designed to run on the developers local machine when running manually So we need to add some documentation somewhere about pre-commit, how to install it and work with it locally. For this hook Some example docs we could add might be: pre-commitWe run pre-commit with GitHub Actions so installation on The pre-commit configuration file The hooks run when running
Sometimes you might need to skip a hook to commit because the hook is stopping you from committing or your computer
The same applies when running pre-commit:
Occasionally you can have more serious problems when using
If you just want to run one hook for example just run the
|
|
@blueorangutan package |
|
@jbampton a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
vishesh92
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm
@jbampton This is good. I believe that cloudstack website (https://github.com/apache/cloudstack-www) would really benefit from this same change since it has a lot of images.
I will add |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15042 |
|
@blueorangutan package |
|
@jbampton a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 15066 |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15074 |
"Lossless compression is a data compression technique where the original data can be perfectly reconstructed from the compressed data. In essence, no information is lost during compression and decompression, making it ideal for situations where data integrity is critical"
https://en.wikipedia.org/wiki/Lossless_compression
https://github.com/oxipng/oxipng
https://github.com/oxipng/oxipng?tab=readme-ov-file#git-integration-via-pre-commit
Ran pre-commit here locally and it compressed the images on first run.
So we have less data for some images with the same quality.
Less data means less to download etc and saves bandwidth.
Description
This PR adds another check / hook / test to our pre-commit framework.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Ran locally
pre-commit run --all-filesHow did you try to break this feature and the system with this change?