๐จImage Color Palette & Contrast Extractor Documentation & Guide
๐How to Use This Tool
- Upload Image File: Drag and drop any JPEG, PNG, WebP, or SVG file. The image is processed entirely within your browser's canvas memory.
- Configure Palette Sample Size: Choose how many dominant swatches to extract (5, 8, 10, or 12 colors) and color quantization precision.
- Click Extract Color Palette: Click Extract Color Palette to run the k-means clustering algorithm and render the interactive color swatches.
- Copy Color Codes or Export CSS: Click any color swatch to copy HEX or OKLCH values, or export complete Tailwind CSS and CSS Variable design token blocks.
โ๏ธTechnical & Educational Details
Extracts raw ImageData pixels from an HTML5 Canvas context and groups 3D RGB color vectors using median cut and k-means clustering. Perceptually uniform OKLCH coordinates are computed using linear sRGB to CIE XYZ to Oklab matrix transformations to ensure luminance accuracy.
๐กPractical Use Cases & Best Practices
- Extracting brand color schemes and mood boards from photography, logos, and UI screenshot references.
- Generating accessible website design tokens and CSS variables directly aligned with product imagery.
- Auditing dominant background colors to select high-contrast foreground text colors for social media banners.