wagtail / wagtail.org

Wagtail’s official marketing website
https://wagtail.org/
66 stars 60 forks source link

Use Calibre's image actions to compress images in PRs #353

Open zerolab opened 1 year ago

zerolab commented 1 year ago

https://github.com/calibreapp/image-actions

Previously done manually (e.g. #285)

udbhavsomani commented 1 year ago

Hi @zerolab, I am new to contributing to wagtail, shall I proceed with this issue if not resolved already?

zerolab commented 1 year ago

Hey @udbhavsomani thank you for expressing your interest. Go for it. The rule is that unless the issue or a comment on the issue explicitly says not to, and there is no-one else who is working on it, then feel free to leave a note that you are working on it, or just open a draft PR. See https://dev.to/lb/ten-tasty-ingredients-for-a-delicious-pull-request-hgc for a lot of useful tips

udbhavsomani commented 1 year ago

Hi @zerolab, please review my PR: https://github.com/wagtail/wagtail.org/pull/359

thibaudcolas commented 11 months ago

I’d like to propose we don’t do this via GitHub Actions, and instead do it manually. We can document the process to do it manually via something like Squoosh if we want, which should give the same image optimisation benefits without the drawbacks I foresee.

The drawbacks are:

  1. As-is, the Calibre action will always attempt to re-optimise images no matter how many times it’s already attempted in the past (see https://github.com/calibreapp/image-actions/issues/92). This is massively wasteful on CPU, which has a clear energy and environmental cost.
  2. If the Calibre action decides to optimise an image, then it’s an extra commit with the newly-compressed images. This effectively at least doubles the space images will take in the git history (as many times as there’s been optimisations). Whereas if we optimise more manually we can be more cautious about how many times we do so and whether the savings are worth the bloat in the git history.

The possible benefits also seem way too small to me:

So – if we want to improve on image size, my preference would be to:

  1. Convert all raster images we can to SVGs. For example we could push harder on SVG favicons.
  2. Document how we optimise the raster images we keep