Skip to content

Limit Oxipng to using no filters#110

Merged
flother merged 3 commits intomasterfrom
only-none-filter
Dec 29, 2025
Merged

Limit Oxipng to using no filters#110
flother merged 3 commits intomasterfrom
only-none-filter

Conversation

@flother
Copy link
Owner

@flother flother commented Dec 28, 2025

It came up in the discussion on #94 that, by default, Oxipng (the PNG encoder used by Spreet) will perform compression trials using four filters: None, Sub, Entropy, and Bigrams. And it turns out that None (i.e. no filter) is almost always the best choice for spritesheets (where best means smallest PNG output).

That means there's an optimsation available to Spreet. Instead of using the defaults and letting Oxipng try all four filters, Spreet could just limit it to only using None. Benchmarking Spreet using a handful of sprite collections suggests this can speed things up by 7-12% overall.

It came up in the discussion on GitHub PR #94 that, by default, Oxipng
(the PNG encoder used by Spreet) will perform compression trials using
four filters: none, sub, entropy, and bigrams. And it turns out that
None (i.e. no filter) is almost always the best choice for spritesheets
(where best means smallest PNG).

That means there's an optimsation available to Spreet. Instead of using
the defaults and letting Oxipng try all four filters, Spreet could just
limit it to only using None. Benchmarking Spreet using a handful of
spritesheets suggests this can speed Spreet up by 7-12% overall.
@flother
Copy link
Owner Author

flother commented Dec 29, 2025

Of the project's 16 fixtures, 12 were unchanged, three were smaller, and one was larger. I tried this out on icons from osm-bright-gl-style, openstreetmap-americana, Mapbox's basic, and whaam styles, and the ~1000 icons from openstreetmap-carto; spritesheets generated from all those remained unchanged in file size.

I'm not sure why three fixtures are smaller. Running oxipng with -o 2 (default) locally chooses the None filter for them all, so I don't know why they weren't at the smaller size before. The one larger fixture is because the bigrams filter works best for it. Regardless, I think this is a positive change overall.

@flother
Copy link
Owner Author

flother commented Dec 29, 2025

For future reference, OptiPNG's guide to PNG optimisation was useful for understanding the encoding process.

@flother flother merged commit 12adaa0 into master Dec 29, 2025
5 checks passed
@flother flother deleted the only-none-filter branch December 29, 2025 15:49
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.

1 participant