Color

Color Palette from Image Guide: Dominant Colors, Pixels and Alpha

·

An image palette extractor summarizes prominent color groups in a picture. ToolMellow opens a local JPG, PNG or still WebP, resizes a copy for approximate dominant-color extraction, and lets you inspect individual pixels from the full decoded canvas. Choose the image, set Sampling backdrop and Palette colors, then press Extract palette.

The palette and pixel inspector answer different questions. Palette colors are grouped averages from a small sample; a selected pixel comes from the browser-decoded full-size canvas. Neither is a certificate of the original file’s encoded color bytes, exact brand-color coverage or print-profile accuracy. This guide explains the controls, alpha handling, percentages, exports and separate clearing actions.

Color palette from image

Load a local image and extract its palette

Use Sample a local image or focus the paste area and paste an image with Ctrl+V or Command+V. The tool takes one selected file, or the first image file found in that clipboard event. It validates the image before drawing a full decoded canvas. Loading starts at coordinates 0,0 but does not automatically sample that pixel or extract a palette.

Sampling backdrop starts as white, Keep sampled alpha starts off, magnification starts at 12× and Palette colors starts at six. Choose the backdrop and requested count, then press Extract palette. Click a palette swatch to send its representative color into the shared color editor and recent-swatch history. Inspect a particular pixel separately when you need a local reading.

  • Keep the source image and note the backdrop and requested count used for an extraction.
  • Use the palette as a design starting point, then inspect important edges, text and small details separately.
  • Re-extract after changing the backdrop or requested count; old results are cleared rather than silently recalculated.

Supported files and inclusive image limits

Loading supports JPG, PNG and still WebP based on the inspected file header, not merely its filename. Animated PNG and animated WebP are rejected by the preflight checks, and unsupported formats need a suitable still-image export. There is no remote-URL image loader or image batch in this workspace.

The limits below apply before and after decoding as appropriate. At most 25,000,000 bytes is a decimal file-size ceiling, rather than 25 MiB. The header checks and actual decoded dimensions both protect the allocation. A supported-looking header is not a guarantee that a corrupt file will decode; export a fresh supported image if it cannot be opened.

Supported files and inclusive image limits
BoundaryAllowed maximum
One file25000000 bytes, inclusive
Decoded image area24000000 pixels
Either decoded side12000 pixels
Source formatsJPG, PNG, still WebP

W3C File API: Local File and Blob dataMDN: createImageBitmap decoding, orientation and color options

How the approximate dominant palette is calculated

Extraction draws an aspect-preserving copy no larger than 256 pixels on either side, without enlarging a smaller image. Browser image smoothing during this resize can blend edge colors; the exact resampling filter is not selected by this tool. It then reads the sampled pixels, discards only those with alpha zero, and composites every other pixel over Sampling backdrop.

The composed channels are grouped into 4-bit-per-channel RGB buckets using floor(channel/16). Each occupied bucket counts its samples and averages their composed RGB channels. The largest counts are selected, and representative averages are rounded to integer HEX colors. This is a bounded grouping algorithm, rather than semantic brand recognition, a list of every original color or perceptual clustering.

How the approximate dominant palette is calculated
StageActual effect
ResizeAspect-preserving sample with each side at most 256 pixels
TransparencySkip alpha 0; composite other samples over the backdrop
Group16 channel bands per R/G/B channel
SelectSort occupied buckets by sampled count
RepresentRounded average RGB, rather than the most frequent exact source pixel

MDN: CanvasRenderingContext2D.drawImage and scalingMDN: Canvas imageSmoothingEnabled

Requested count and what the percentages mean

The count selector offers 2, 3, 4, 5, 6, 8, 10 or 12 colors. It is a maximum requested number of occupied buckets, so the result can contain fewer entries, including one. A fully transparent sampled image yields no visible palette. Rounded bucket representatives are approximate and should not be treated as a guarantee of that many distinct original image colors.

Each percentage is the bucket count divided by all nonzero-alpha pixels in the resized sample. A partially transparent sample counts once, rather than being weighted by its opacity. Selecting only the top buckets does not renormalize their shares to 100%. The interface rounds shares to one decimal place; JSON keeps the computed numbers. These are sampled color-group shares, not exact original-image area or brand percentages.

Palette composition and Keep sampled alpha have separate jobs

Palette extraction always composites nonzero-alpha samples onto the chosen opaque backdrop and outputs opaque representative HEX colors. Fully transparent samples are ignored. Keep sampled alpha controls subsequent individual-pixel sampling, not this palette algorithm. A different backdrop can change partial-alpha sample colors, grouping and the resulting palette.

Changing Sampling backdrop or Palette colors clears the extracted palette; press Extract palette again. Changing the backdrop or Keep sampled alpha does not automatically replace the color already held in the shared editor. Press Sample selected pixel, click a pixel or move its coordinates to obtain a reading using the current sampling options.

W3C Compositing and Blending 1: Alpha over a backdropMDN: CanvasRenderingContext2D.getImageData pixel readings

Small synthetic examples of buckets and transparency

The examples below describe exact RGBA sample arrays passed to the grouping helper. They isolate its rules; a real image’s browser decoding and resize can produce different sampled values. Requested count is two, and the white backdrop is used unless another backdrop is specified.

Two different reds in the same channel band can average into a new representative color. A half-alpha red sample is also composited rather than counted as a separate transparent HEX palette color. Use these examples to distinguish average color, sample share and alpha from a guarantee about the original file.

Small synthetic examples of buckets and transparency
Sample dataResultMeaning
Two opaque red pixels, one opaque green, one alpha 0 pixel#FF0000 about 66.67%; #00FF00 about 33.33%The transparent sample is excluded from the denominator
Opaque RGB 16,0,0 and 31,0,0One #180000 entry at 100%A rounded bucket mean can be absent from the original samples
One red pixel with alpha byte 128 over white#FF7F7F at 100%Nonzero alpha counts once after composition
That same alpha 128 red over black#800000 at 100%Backdrop changes the representative; requested two can return one

Inspect full decoded pixels with coordinates and keys

The displayed image may be scaled to fit its preview, but selection reads from the full decoded canvas. Clicks map the displayed position into that canvas. Pixel X and Pixel Y are zero-based, rounded and clamped to its bounds. Coordinates describe the browser-decoded image dimensions, which can reflect decoding/orientation behavior rather than a raw compressed-file byte offset.

Focus the image to use its keyboard controls, or enter coordinates and use Sample selected pixel. A reading updates the shared color editor and remembers the sampled color in recent swatches. Loading an image only prepares the view; the initial coordinate display does not establish that the editor already contains pixel 0,0.

Inspect full decoded pixels with coordinates and keys
ControlEffect
Arrow keysMove and sample one pixel
Shift + arrowMove and sample ten pixels, with boundary clamping
Enter or Space on the imageSample the currently selected point
Pixel X / Pixel YSelect a bounded full-canvas coordinate

MDN: createImageBitmap decoding, orientation and color optionsMDN: CanvasRenderingContext2D.getImageData pixel readings

Magnification and browser-decoded color precision

Magnification offers 6×, 12× or 20× with a 180×180 backing detail canvas. Responsive CSS can display that canvas at a different size, including 140×140 on narrow screens. The magnifier disables smoothing for enlargement so the intended pixel cells remain visible. This differs from the smoothed display/resize used for fitting the image and extracting its small palette sample.

ImageBitmap decoding and canvas color/alpha handling can involve browser conversion and premultiplied-alpha round trips. The default canvas reading here is an 8-bit sRGB-oriented result, not guaranteed original ICC/profile or compressed-file color-byte precision. Especially near transparent edges, inspect the decoded reading for this workflow and keep the original file for color-managed or forensic needs.

MDN: createImageBitmap decoding, orientation and color optionsMDN: CanvasRenderingContext2D.getImageData pixel readingsMDN: Canvas imageSmoothingEnabled

Copy or download HEX, CSS and JSON palette data

Copy palette HEX copies one HEX value per line. Palette downloads offer TXT, CSS and JSON filenames. The CSS contains root custom properties named in palette order; JSON is an array of objects with HEX and computed percentage fields. All three palette download blobs use UTF-8 text/plain, even though their extensions differ.

Export again after a new extraction. A saved file or clipboard entry is a snapshot and does not update when settings change. If the sampled image has no visible palette, the palette export controls are absent. Palette exports are separate from the shared editor’s saved-swatch downloads.

Copy or download HEX, CSS and JSON palette data
Palette formatFilenameContents
TXTtoolmellow-palette.txtOne HEX per line
CSStoolmellow-palette.css:root with --palette-1, --palette-2 and later variables
JSONtoolmellow-palette.jsonArray entries with hex and percent numeric-share data

Selected colors and the separate 24-swatch history

Clicking a palette color or sampling a pixel sends a color to the shared editor and remembers it. The history holds up to 24 recent values, deduplicated by their RGB/RGBA representation and ordered with the newest first. Extracting a palette does not automatically save every palette entry into that history.

The editor’s initial color is #7D9065, separate from a newly loaded image. It exposes HEX, RGB, HSL, RGB percent, normalized RGBA and CSS-variable representations, plus color-channel edits and a visual picker. Save swatch remembers the current edited color. Saved-swatches JSON/CSS downloads have their own filenames and MIME types, distinct from the sampled palette exports.

W3C CSS Color 4: sRGB values and alpha representations

Retained pixel alpha versus an opaque sampled color

With Keep sampled alpha off, pixel sampling composites the decoded pixel over Sampling backdrop and rounds its RGB channels to an opaque color. With it on, the decoded RGB and 8-bit alpha are retained in the sampled color representation. The palette remains opaque in either setting.

The shared editor’s preview is composited on white, which is separate from a changed sampling backdrop. HEX encodes alpha in 8 bits, while RGB/HSL representations retain the stored decimal alpha. A current sample, remembered swatch, changed editor color and extracted palette are separate values; editing one does not reprocess the image or rewrite every saved result.

MDN: CanvasRenderingContext2D.getImageData pixel readingsW3C Compositing and Blending 1: Alpha over a backdropW3C CSS Color 4: sRGB values and alpha representations

Clear image, Clear swatches and the current color

Clear image removes the loaded sampler image and extracted palette, clears child notices/errors, and hides its sampling view. It retains sampling choices such as backdrop, requested count, magnification and Keep sampled alpha. It does not reset the parent’s current color or remembered swatches. Clear swatches empties the saved-swatch list separately and also leaves the current color in place.

Loading another file first clears the prior image/palette. If that new load fails, the old sampler view is not restored. A generation counter prevents a stale completed load from replacing a newer choice; it does not abort an already running decode. Refreshing or leaving the page resets its in-memory state. Clipboard data and downloaded files remain outside these actions.

Clear image, Clear swatches and the current color
ActionState affected
Clear imageSampler image/palette, while parent color/history remain
Clear swatchesSaved-swatch list, while current color remains
Backdrop or requested-count changeExtracted palette cleared; re-extract explicitly
Refresh or leave pageWorkspace in-memory state is reset

Use a palette as an approximation, then review the design

Resizing, bucket boundaries, alpha, the backdrop and the chosen maximum count can all affect the result. Small details may disappear or blend into new colors during sampling. Percentage ties and rounded representatives are not a ranking of semantic importance, exact coverage or accessibility quality.

Use the output to explore a palette, then check important colors and real UI surfaces separately. The contrast checker can evaluate relevant solid pairs, but extracting dominant colors does not establish readable text or whole-page conformance. This tool does not provide remote image fetching, color-profile certification, print-color matching or semantic logo/brand detection.

Local processing and the optional screen picker

Preflight, decoding, drawing, pixel reads and palette extraction use the selected local file in the browser. The image is not uploaded to a palette-calculation server. The public website still makes ordinary hosting and analytics requests, so local processing does not imply anonymity or zero infrastructure logging.

Where the browser exposes EyeDropper, the shared editor can offer Pick from screen. That is a separate user-initiated capability returning an opaque sRGB color, not the image palette algorithm or a guarantee of support in every browser/embedding context. Use local-image selection when the optional screen capability is unavailable.

MDN: createImageBitmap decoding, orientation and color optionsW3C File API: Local File and Blob dataMDN: EyeDropper user-initiated screen color selection

Embed the palette extractor with its backlink

Use the integration section below the workspace to copy or download the localized HTML snippet. Paste it into a platform that permits the iframe and sizing script, and retain the visible backlink to the matching ToolMellow image-palette page. The supplied credit link uses nofollow and noopener.

Test local file selection, paste/clipboard permissions and the layout on a narrow screen in the host context. The embed keeps the same limits, approximation and state boundaries. Its height messages size the frame; they are not an API for remote image fetching, batched analysis or automatic host-page color extraction.

Common questions

How do I extract a palette from an image?

Choose or paste a supported local still image, set Sampling backdrop and Palette colors, then press Extract palette. Loading alone does not extract or sample the initially displayed coordinate.

Are these every original color in the image?

No. The tool groups an aspect-preserving sample of at most 256 pixels per side into RGB buckets and outputs rounded means of selected dominant buckets. Small details and exact source colors can change or be omitted.

Why can I get fewer colors than requested?

The requested count limits selected occupied buckets. The sample may have fewer buckets, including only one. A fully transparent sample yields none; representatives do not guarantee that many unique original colors.

Why do percentages not add up to 100%?

Shares use all nonzero-alpha sampled pixels as the denominator, not only selected buckets. Omitted buckets retain their share. The visible percentages are also rounded to one decimal place.

Does a partially transparent pixel count less?

It counts once if its alpha is nonzero, after its RGB is composited on the backdrop. This is not alpha-weighted coverage. Alpha-zero samples are excluded.

Does Keep sampled alpha change the extracted palette?

No. It controls later individual-pixel samples. Palette extraction always composites visible samples on Sampling backdrop and produces opaque representative colors.

Does changing the backdrop automatically update everything?

It clears the extracted palette and redraws the relevant view. Re-extract for a new palette and explicitly resample for an updated selected color. The parent color/history are not automatically replaced.

What does original-pixel inspection mean here?

It reads the full browser-decoded canvas rather than the reduced palette sample or fitted preview. It does not guarantee raw encoded-file, ICC/profile or hidden-alpha color-byte identity.

Which image files and limits are supported?

JPG, PNG and still WebP are checked by header, with at most 25000000 bytes,24000000 pixels and 12000 pixels per side. Animated/unsupported/corrupt files need a suitable still-image export.

How do I export the palette?

Use Copy palette HEX or TXT/CSS/JSON palette downloads. JSON includes hex and computed percent fields; CSS uses numbered root variables. These palette blobs are UTF-8 plain text and separate from saved-swatch exports.

What does Clear image remove?

It clears the sampler image and extracted palette, not the shared current color or saved-swatch history. Clear swatches removes that history separately. Clipboard contents and downloaded files are outside both actions.

Are all palette colors automatically saved as swatches?

No. Selecting a palette entry or sampling a pixel remembers that chosen color, and Save swatch can remember the current edited value. Extraction alone does not save the whole palette to the 24-entry history.

Is the image uploaded for palette extraction?

No image upload to a calculation server is performed. The selected file is processed locally; ordinary website hosting/analytics requests still occur. Local processing is not a zero-logging or anonymity certification.

Can I embed the image palette extractor?

Use its localized HTML snippet, retain the visible ToolMellow backlink and verify file/paste/clipboard/iframe support. It remains a local interactive palette/inspection tool with the same limitations.

Sources and further reading

Put it into practice.

Related guides