Skip to content
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

Compress field images with oxipng #103

Merged
merged 4 commits into from
Oct 1, 2024
Merged

Compress field images with oxipng #103

merged 4 commits into from
Oct 1, 2024

Conversation

Gold856
Copy link
Contributor

@Gold856 Gold856 commented Sep 26, 2024

I used oxipng with the arguments -Z -o max --fast to compress each image, then a second pass with -o max --fast --strip safe to squeeze a few more bytes out. This reduced the size of the field images by ~50%, and reduced the size of the whole app by ~25%.

@Gold872
Copy link
Owner

Gold872 commented Sep 26, 2024

I think this is a good improvement to add. I'd prefer adding this as a GitHub CI action so it doesn't have to be done manually when new images are added

@Gold856 Gold856 force-pushed the main branch 3 times, most recently from a1523d3 to 866ee3c Compare September 26, 2024 21:09
I used oxipng with the arguments `-Z -o max --fast` to compress each image. This reduced the size of the field images by ~50%, and reduced the size of the whole app by ~25%.
@Gold856 Gold856 changed the title Compress field images with Zopfli Compress field images with oxipng Sep 26, 2024
@Gold856
Copy link
Contributor Author

Gold856 commented Sep 26, 2024

The CI workflow has been added as a comment command /optimize. You'll need to add a sercet called IMAGE_COMPRESSOR_TOKEN that has push access to allow GitHub Actions to commit and push to PR branches.

Copy link

codecov bot commented Sep 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.94%. Comparing base (f0c2bf5) to head (65081bb).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #103   +/-   ##
=======================================
  Coverage   63.94%   63.94%           
=======================================
  Files          77       77           
  Lines        7983     7983           
=======================================
  Hits         5105     5105           
  Misses       2878     2878           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Gold872
Copy link
Owner

Gold872 commented Sep 28, 2024

What I was originally thinking for the CI is for it to compress the images before building, that way it's done automatically without any need for comment commands or github tokens. This way works too but I'd prefer making the compression an internal step before the CI build.

@Gold856
Copy link
Contributor Author

Gold856 commented Sep 28, 2024

We’d need a token anyways to be able to push commits and I’m not a big fan of adding commits to a PR automatically. The compression process also takes several minutes (20+ per image), and I don’t want to hold up a build just for that. I think just running an optimize command every time a PNG is modified/added is a good compromise (I doubt PNGs are modified/added often anyways).

@Gold872
Copy link
Owner

Gold872 commented Oct 1, 2024

Since it takes that long to optimize the images I think it's best to just remove the CI do the compression manually. You're right that there's only a new image once a year, and now that I think of it, trying to simplify it ends up creating more work.

I appreciate your work on this I think this is a good enhancement

@Gold872 Gold872 merged commit 3e1dc36 into Gold872:main Oct 1, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants