Expand description
Dominant-colour palettes, matching Eagle’s palettes field.
Eagle runs modified median cut quantization (MMCQ, the algorithm behind color-thief) on a copy of the image at most 360 px wide, then turns box populations into percentages. This port keeps Eagle’s exact control flow, quirks included, so the same pixels give the same palette:
- the colour bounds are tracked with
if min .. else if max, so a channel’s first value only ever sets its minimum; - each of the two splitting passes stops after 5 iterations, which caps a palette at about 11 colours;
- boxes are kept in a lazily sorted queue whose tie order matters.
Constants§
- ANALYSIS_
WIDTH - Width of the image Eagle analyses.
Functions§
- analysis_
image - The image Eagle hands to the quantizer:
imgscaled down (never up) to at mostANALYSIS_WIDTHwide, keeping the aspect ratio. - extract
- Extracts the palette Eagle would store for
img. - from_
rgba - Extracts a palette from an RGBA buffer that is already analysis-sized.
- refresh_
source - The picture Eagle analyses when a palette is refreshed: the original
when the item has
noThumbnail(a small SVG is rendered at its own size), otherwise the thumbnail file.Nonewhen there is nothing to read.