Skip to main content
CS

Color Scheme from Image

Generate a complete 12-colour design scheme from any image — primary, secondary, accent, tints, shades, plus a live preview card.

Did you like the tool? Thanks!
Share:

Hover over swatches to see details. Click to copy hex code.

Live Preview

Card Title

This is a sample body paragraph styled with the generated colour scheme to preview how the colours work together in context.

How to Use Color Scheme from Image

Upload an image and the tool extracts 5 dominant colours, then algorithmically generates a 12-colour scheme suitable for UI design. The scheme includes Primary, Secondary, Accent, Background, Text colours, plus lighter and darker variants (tints and shades) of the main colours. Each swatch shows its label, hex code, and is clickable to copy. A miniature preview card shows the scheme applied to a mock UI component — title, text, background, and a button — so you can evaluate the palette in context before exporting it.

About Color Scheme from Image

A colour scheme — sometimes called a design system palette, theme, or colour tokens — is a set of colours with assigned roles (background, text, primary action, accent, etc.) that work together to create visual hierarchy and consistency across a UI. Picking these colours individually by eye is time-consuming and error-prone: the primary and accent might clash, the text might lack sufficient contrast against the background, or the lighter variants might not feel like they "belong" to the same family. This tool starts from the premise that a good photo already contains a harmonious colour palette — nature, architecture, and professional photography all exhibit colour combinations that our brains perceive as pleasing. By extracting the dominant colours from an image and then algorithmically assigning them design-system roles, the tool bridges the gap between a visual inspiration source and a practical, usable UI colour scheme. The process works in three stages: **Stage 1 — Dominant colour extraction.** Using the same simplified colour quantization algorithm as the Image Palette Extractor (4-bit-per-channel binning, top-5 bins by pixel count, average colour per bin), the tool extracts the five most representative colours from the uploaded image. **Stage 2 — Role assignment.** The five extracted colours are sorted and assigned to design roles based on their objective properties: - **Primary:** The most dominant colour overall (highest pixel count). This is the main brand/action colour. - **Secondary:** The second most dominant colour. - **Accent:** Among the top 5, the colour with the highest saturation (computed in HSL space, `S = (max(R,G,B) - min(R,G,B)) / (1 - |2L - 1|)` normalised to 0–1). This is the "pop" colour for call-to-action highlights. - **Background:** The lightest colour among the top 5 (highest L in HSL). If none is sufficiently light (L < 85), a very light neutral (#F5F5F5 or similar) is derived from the average hue of the palette. - **Text:** The darkest colour among the top 5. If none is sufficiently dark (L > 25), a near-black (#1A1A1A or similar) is derived from the palette's average hue. **Stage 3 — Variant generation.** Tints and shades for Primary, Secondary, and Accent are generated by adjusting lightness in HSL space while holding hue and saturation constant. The Light variant blends the base colour toward white (L → 100), while the Dark variant blends toward black (L → 0), using a fixed step (e.g., 30% lightness shift in each direction). A Neutral colour — a desaturated, mid-lightness colour derived from the palette average — completes the set of 12. **Preview card:** To ground the abstract swatches in a realistic context, the tool renders a miniature preview card — a rectangular area styled with the generated scheme. It shows a title (using the Text colour), a body paragraph (Text at reduced opacity), a background fill (Background colour), and a button (Primary colour with Text colour for its label). This gives an immediate, intuitive sense of whether the scheme works together in practice, without having to copy values into a separate design tool. All 12 swatches are displayed in a grid. Each shows a filled square, a role label (e.g., "Primary"), and the hex code. Clicking any swatch copies its hex code. The entire operation runs client-side — the image never leaves your browser.

Details & Tips

Full algorithm walkthrough: **1. Image loading and scaling:** Same as the other canvas tools — FileReader → Image object → drawImage onto offscreen canvas, capped at 900px max width. **2. Dominant colour extraction (same as palette extractor):** - Sample stride: 6 pixels in both dimensions. - Alpha threshold: skip pixels with A < 128. - Binning: each channel reduced to 4 bits (`R >> 4`, etc.), bin index = `(r4 << 8) | (g4 << 4) | b4`. - Accumulate counts and channel sums per bin. - Sort bins by count descending, take top 5. - Compute average colour per top bin: `Math.round(sum / count)` per channel. - Output: 5 colours as `{ hex, r, g, b, count }` objects. **3. Role assignment logic:** - Sort the 5 extracted colours by `count` descending. - Primary = colours[0], Secondary = colours[1]. - Accent: compute HSL saturation for each of the 5. Pick the one with the highest S value (using the standard RGB-to-HSL saturation formula on the average colour of each bin). - Background: compute HSL lightness for each of the 5. Pick the one with highest L. If max L < 85, create a derived background: take the average hue of the 5 colours, set S = 5%, L = 95%, then convert back to RGB → hex. This produces a very light, warm/cool tinted off-white that harmonises with the palette. - Text: compute HSL lightness for each of the 5. Pick the one with lowest L. If min L > 25, create a derived text colour: take the average hue, set S = 3%, L = 10%, producing a near-black with a subtle tint matching the palette. **4. Variant generation (tints and shades in HSL):** For each of Primary, Secondary, and Accent: - Convert to HSL. - **Light variant:** L_light = Math.min(100, L_base + 30). This shifts lightness ~30 points toward white. Convert back to RGB → hex. - **Dark variant:** L_dark = Math.max(0, L_base - 30). Shifts lightness ~30 points toward black. Convert back to RGB → hex. If the base colour is already very light (L > 85), the Light variant clamps at 100 (white). If very dark (L < 15), the Dark variant clamps at 0 (black). - **Neutral:** Average the hues of all 5 extracted colours. Set S = 8%, L = 65% (a mid-grey with a subtle warm/cool tint from the palette). **5. Display grid:** 12 swatches in a 4-column grid (3 columns on small screens). Each swatch card contains: - A colour square (approx 48×48px with rounded corners). - A label: "Primary", "Secondary", "Accent", "Background", "Text", "Primary Light", "Primary Dark", "Secondary Light", "Secondary Dark", "Accent Light", "Accent Dark", "Neutral". - The hex code in monospace text below. - Click handler: copy hex to clipboard. **6. Preview card:** A dedicated section below or beside the swatch grid. It renders a small card element styled inline with CSS variables derived from the scheme: - Card background: Background colour. - Card border: a slightly darker shade (Neutral colour at reduced opacity). - Title text: Text colour, bold font. - Body text: Text colour at ~70% opacity. - Button: Primary colour background, Text colour (or white if Text is dark) for label, rounded corners. The preview card is purely visual — it is a styled `<div>`, not a canvas, using inline `style` attributes bound to Alpine data. **Edge cases:** - Image with fewer than 5 distinct colours: the palette extraction returns whatever non-zero bins exist. The tool displays only as many swatches as there are colours, and the preview card adapts. - All colours similar lightness: Background and Text assignments may use derived colours. This is correct — the tool should not force a mid-tone as background when the user's image is genuinely all mid-tones. - Highly saturated image: Accent and Primary might be the same colour. In this case, Accent defaults to the colour with second-highest saturation. - Solid black or white image: the tool produces a grayscale scheme. **Performance:** The extraction uses the same fast binning algorithm as the palette extractor. The 12-colour grid and preview card are pure DOM rendering — no canvas work beyond the initial extraction. Total processing time is well under 100ms.

Frequently Asked Questions

How does the colour scheme generator work?
It extracts 5 dominant colours from your image using colour quantization, then algorithmically assigns them design roles (Primary, Secondary, Accent, Background, Text) based on pixel frequency, saturation, and lightness. Tints, shades, and a Neutral colour are generated to complete a 12-colour UI palette.
How is the Primary colour chosen?
The Primary colour is the most frequent colour in the image — the bin with the highest pixel count after quantization. It becomes the main action/brand colour.
How is the Accent colour chosen?
Among the top 5 extracted colours, the one with the highest saturation (in HSL space) is selected as the Accent. Saturation measures colour intensity — highly saturated colours "pop" and work well as call-to-action highlights.
What if my image does not have a suitable background colour?
If the top 5 colours are all dark or mid-tone (no colour with lightness above 85 in HSL), the tool derives a very light near-white colour tinted with the average hue of the palette. This ensures usable contrast for text.
How are the Light and Dark variants generated?
Each main colour (Primary, Secondary, Accent) is converted to HSL, and a Light variant is created by shifting lightness ~30 points toward 100 (white), while a Dark variant shifts ~30 points toward 0 (black). The hue and saturation are preserved.
What is the Neutral colour?
Neutral is a desaturated mid-grey tinted with the average hue of the extracted palette. It is intended for borders, dividers, disabled states, and subtle background variations.
What does the preview card show?
A small mock UI component — a card with a title, body text, background, and a button — styled entirely with the generated colour scheme. This helps you evaluate the palette in a realistic design context at a glance.
How many colours are in the final scheme?
12 colours total: Primary, Secondary, Accent, Background, Text, Primary Light, Primary Dark, Secondary Light, Secondary Dark, Accent Light, Accent Dark, and Neutral.
How do I copy a colour from the scheme?
Click any swatch and its 7-character hex code (with #) is copied to your clipboard. A "Copied!" confirmation appears briefly. Each swatch is clickable.
What image formats are supported?
Any format your browser can render: JPEG, PNG, WebP, BMP, GIF, AVIF, and SVG. The analysis is performed on the rendered canvas pixels.
Is my image uploaded to a server?
No — the image is loaded locally via FileReader and all colour extraction runs in your browser using the Canvas API. Nothing is transmitted anywhere.
Can I use this scheme directly in my CSS?
Yes — copy the hex codes and paste them into your CSS custom properties (`--primary: #...;`, etc.). The scheme is designed to follow standard design-system token naming conventions for easy integration.

Part of These Collections

Also Available As

color scheme from image, ui color palette from photo, design system palette generator, extract color scheme, image to color palette, brand colors from photo, color theme generator, design tokens from image

Found a Problem?

Let us know if something with Color Scheme from Image isn't working as expected.

Thanks — we'll take a look.