Palette-quantize generated brand PNGs#25
Merged
Merged
Conversation
Palette-quantize generated PNGs (Pillow FASTOCTREE) in raster.py — ~70-80% smaller, visually lossless for flat art, alpha preserved on transparent marks. SVGs and external optimizers out of scope. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two tasks: add Pillow + the FASTOCTREE quantize step in raster.py (with tests and regenerated PNGs), then docs/finalize. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Folds a palette-quantization pass into the brand build so every generated PNG is committed in compact indexed-colour form. The art is flat 2–3 colour, so quantizing
rsvg-convert's 32-bit RGBA output to a palette is visually lossless and cuts the large assets ~70–80%:mark-1024~25–36 KB → ~8 KBDone with Pillow (
Image.Quantize.FASTOCTREE, 32-colour palette) inbrand/build/raster.py::_quantize_png, called at the end ofexport_png— no Node, no required system binary. FASTOCTREE preserves alpha, so transparent marks keep clean edges (verified on light/dark). SVGs are deliberately untouched.Design
planning/changes/2026-06-30.03-png-optimization/design.mdplan.mdNotes
tests/test_pngopt.py) assert indexed mode, dimensions, transparency on the marks, size ceilings, and palette reduction; output is pristine. 91 tests pass;just check-planningOK.pngquant/oxipng), the 1280×640-vs-1200×630 ratio, and re-copying the smaller cards into the 7 docs-repo PRs (a follow-up).🤖 Generated with Claude Code