Skip to content

fix(color): recover numeric palette slots lost to transparency - #91

Merged
phil-r merged 1 commit into
mainfrom
fix/color-numeric-transparent-palette
Oct 8, 2026
Merged

phil-r merged 1 commit into
mainfrom
fix/color-numeric-transparent-palette

Conversation

@phil-r

@phil-r phil-r commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Description:

Fix numeric color requests losing a visible color because hidden RGB in transparent pixels consumes a palette slot. Both color profiles retry only when an occupied cluster has no visible pixels before component cleanup. Recovery preserves the numeric count and initialization method, cleans only the final pass, and leaves input arrays unchanged. Cleanup-only losses do not trigger recovery; auto and binary behavior stay unchanged.

This PR includes:

  • Regression tests for hidden RGB, numeric counts, cleanup-only losses, unused centroids, empty images and repeated solves.
  • Updated numeric-count documentation and HTTP profile checks, retaining the independent original-pipeline SVG hash.

How to run:

docker compose --profile testing run --build --rm test \
  python -m pytest vectorizing/tests/test_color_numeric.py \
  vectorizing/tests/test_color_configurations.py

Validation: 827 offline tests and all pre-commit hooks passed. test_integration.py (HTTP/S3/gallery integration) was excluded. Unaffected SVG, RGBA, palette, dimension and bounds captures matched exactly. Visual evidence remains local; no artwork or gallery baselines were uploaded or replaced.

Local benchmarks on the reported PNG (M4 Pro, ARM64 Docker/Python 3.11, single-threaded, 5 fresh-process samples plus warmup):

Profile Original, 2 colors Fixed, 3 colors
current 213 ms 352 ms
experimental 169 ms 271 ms

Recovery adds a bounded extra clustering pass. No consistent slowdown was measured on unaffected inputs. Timing excludes decoding, HTTP/S3 and rasterization; production concurrency was not tested.

Checklist (based on PR guidelines):

  • I have self-reviewed this PR, according to these points
  • This PR falls into maximum three of these categories
  • I feel comfortable taking responsibility for merging this code to production
  • The code is high quality, well-tested, follows styles guides (Frontend), clean, and well documented

Retry only when an occupied raw cluster has no visible pixels, before component cleanup. Keep numeric counts and seed methods unchanged, clean only the final pass, and leave solver input arrays untouched.

Add regressions for transparent palettes, cleanup-only losses, unused centroids, empty images and repeated solves. Preserve the original lower-level SVG hash and HTTP profile contracts.
@phil-r
phil-r merged commit 9640952 into main Oct 8, 2026
2 checks passed
@phil-r
phil-r deleted the fix/color-numeric-transparent-palette branch October 8, 2026 12:50
phil-r added a commit that referenced this pull request Oct 8, 2026
Retry only when an occupied raw cluster has no visible pixels, before component cleanup. Keep numeric counts and seed methods unchanged, clean only the final pass, and leave solver input arrays untouched.

Add regressions for transparent palettes, cleanup-only losses, unused centroids, empty images and repeated solves. Preserve the original lower-level SVG hash and HTTP profile contracts.
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