Skip to content

Commit 62d1425

Browse files
lesnik512claude
andauthored
Palette-quantize generated brand PNGs (#25)
* docs: design brand PNG optimization 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> * docs: implementation plan for brand PNG optimization 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> * feat(brand): palette-quantize generated PNGs (Pillow FASTOCTREE) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: convert to RGBA to avoid PIL tRNS warning * docs(brand): document PNG quantization * docs: correct uv.lock note in png-optimization spec (repo tracks it) * docs: scope the PNG shrink claim to large assets * build: sync optimized social card into docs/assets (served og:image) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent eb1504f commit 62d1425

60 files changed

Lines changed: 517 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎architecture/brand-marks.md‎

Lines changed: 5 additions & 0 deletions

‎brand/README.md‎

Lines changed: 6 additions & 0 deletions

‎brand/build/raster.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22
import subprocess
33
from pathlib import Path
44

5+
_PNG_COLORS = 32 # palette size; flat art needs few (8 already looked clean; 32 = headroom)
6+
7+
8+
def _quantize_png(path: Path, colors: int = _PNG_COLORS) -> None:
9+
"""Re-save a PNG as an indexed-palette image — visually lossless for flat
10+
art. FASTOCTREE preserves alpha, so it is correct for both the opaque
11+
social cards and the transparent marks. No-op if Pillow is unavailable."""
12+
try:
13+
from PIL import Image
14+
except ModuleNotFoundError:
15+
return
16+
im = Image.open(path).convert("RGBA")
17+
q = im.quantize(colors=colors, method=Image.Quantize.FASTOCTREE)
18+
q.save(path, format="PNG", optimize=True)
19+
520

621
def export_png(
722
svg_path: Path,
@@ -20,4 +35,5 @@ def export_png(
2035
args += ["-h", str(height)]
2136
args += [str(svg_path), "-o", str(png_path)]
2237
subprocess.run(args, check=True)
38+
_quantize_png(png_path)
2339
return True

‎brand/org/apple-touch-icon-180.png‎

-1.37 KB

‎brand/org/avatar-1024.png‎

-6.64 KB

‎brand/org/avatar-circle-1024.png‎

-5.86 KB

‎brand/org/favicon-16.png‎

-89 Bytes

‎brand/org/favicon-32.png‎

-290 Bytes

‎brand/org/favicon-48.png‎

-428 Bytes

‎brand/org/social-card-green.png‎

-17.2 KB

0 commit comments

Comments
 (0)