Extract the dominant colors from any image and get an accessible text-color recommendation for each one.
Hue is a dependency-free Go package built on deterministic median-cut quantization, so the same input image always returns the same palette.
Features
🎨 Dominant Color Extraction
- Configurable palettes: Choose how many dominant colors to extract
- Reliable results: Deterministic median-cut quantization instead of k-means
- Ordered by prominence: Colors are returned from most to least dominant
- Efficient sampling: Bound processing cost even for high-resolution images
♿ Contrast-Aware by Default
- WCAG luminance: Calculates each color’s relative luminance
- Text-color recommendations: Returns black or white based on the best contrast ratio
- Light/dark classification: Identifies colors using a clear luminance threshold
- Ready for interfaces: Build readable, dynamic color themes with confidence
🖼 Image-Friendly Processing
- Transparent pixel handling: Fully transparent pixels are ignored
- Alpha compositing: Semi-transparent colors are represented as they appear on white
- Background cleanup: Optionally ignore near-white or near-black pixels
- Broad image support: Works with the formats supported by Go’s image ecosystem
🛠 Developer Friendly
- Go standard library only
- Simple Go API
- JSON output available
- Predictable performance
- Open source
- MIT licensed
Tech Stack
Language → Go
Dependencies → Go standard library only
Quantization → Deterministic median-cut
Accessibility → WCAG relative luminance and contrast ratios
Output → Go structs or JSON