Skip to content

Optimize PNG images using oxipng #11203

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

Closed
wants to merge 1 commit into from

Conversation

aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Aug 14, 2025

This PR losslessly optimizes the PNG images in this repo with oxipng. This decreases the image sizes, at the cost of increasing the Git history size. Specifically, the command used is oxipng -o max --zopfli --cache --fix where --cache is a feature I added in my fork: oxipng/oxipng#564

Follow-up to this PR: #5254

Alternatively, we could switch to WebP images, but unless somebody does that, this PR is available.

Other PRs changing images like #11149 should be merged ahead of this one.

@Calinou
Copy link
Member

Calinou commented Aug 14, 2025

Alternatively, we could switch to WebP images, but unless somebody does that, this PR is available.

I would prefer switching all PNGs to lossless WebP, which is in fact something I did in the past (...but I apparently never opened a PR for). Lossless WebP basically always wins compared to an highly optimized PNG (although lossy PNG with pngquant might still win, but it's lossy at this point).

This script should do it:

# Install `parallel`, `cwebp` and `sd` first.
shopt -s nullglob globstar
parallel cwebp -z 9 {} -o {.}.webp ::: {about,community,contributing,getting_started,tutorials}/**/*.png
sd ".png" ".webp" {about,community,contributing,getting_started,tutorials}/**/*.rst
# Review replacements and revert those that acted on non-img fields (it will replace text instances in tutorials too).

# The top-level `img/` folder is excluded as it's linked within the engine class reference.

@skyace65
Copy link
Contributor

skyace65 commented Aug 15, 2025

I'd rather we not do this, and just continue to convert stuff to webp as we go. For some pngs that aren't going to change this makes sense, pictures of stuff that's outside of the editor. But for stuff like the translation tutorials the proper solution to the files being too large should be to replace them with up to date files that are webp.

Edit: Also worth pointing out, I very frequently find that the webp's we replace pngs with do end up being larger, which we knew would happen when we decided to move to that format. So again, if we do this, then replace those outdated images with webps eventually we're going to be right back where we started in terms of image size. If that's a big problem right now, we should be figuring out a permanent solution, not a one time fix like this that will have less benefits over time as the docs are updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants