Skip to main content

Extract color palettes from images for web design. Produces LLM-consumable prose with color roles, WCAG contrast pairs, and harmonic relationships.

Project description

palette-extractor

Extract color palettes from images. Produces prose output suitable for LLM consumption, with optional HTML reports for human review.

How it works

Unlike simple color extraction that clusters pixels by RGB similarity, palette-extractor analyzes how colors relate to each other spatially:

  • Adjacency graph — Colors are understood through their neighbors, not in isolation. A yellow next to black has different significance than yellow next to orange.
  • LAB color space — All perceptual calculations use LAB, where distances match human perception. Colors 2.3 units apart are one "just noticeable difference."
  • Role assignment — Colors get roles (dominant, accent, light, dark) based on coverage, contrast, and spatial coherence — not just frequency.
  • Salience over coverage — A rare high-contrast accent can outrank a common background color in visual importance.

Installation

Requires Python 3.10+.

# With uv (recommended)
uvx --from git+https://github.com/Capacap/palette-extractor palette-extractor -i image.png

# Or install globally
uv tool install git+https://github.com/Capacap/palette-extractor
palette-extractor -i image.png

Usage

palette-extractor -i <image_path> [options]

Options:

Flag Description
-i, --input Path to image file (required)
-o, --output Write HTML report. Optionally specify path, otherwise auto-names from input.
--no-downscale Process at full resolution instead of downscaling to 256px

Output

Text output includes:

  • Overview — Scheme classification (monochromatic, analogous, complementary, etc.), lightness/chroma ranges, distribution
  • Colors — Notable colors ranked by prominence with roles: Dominant, Secondary, Accent, Light, Dark
  • Relationships — WCAG-rated contrast pairs and harmonic color pairings

Each color shows hex, RGB, LAB values, coverage percentage, and perceptual notes.

Examples

# Analyze and print to terminal
palette-extractor -i photo.jpg

# Generate HTML report (auto-named photo-palette.html)
palette-extractor -i photo.jpg -o

# Generate HTML report with custom path
palette-extractor -i photo.jpg -o report.html

# Full resolution analysis (slower, more precise)
palette-extractor -i photo.jpg --no-downscale

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

image_palette_extractor-0.2.0.tar.gz (34.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

image_palette_extractor-0.2.0-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file image_palette_extractor-0.2.0.tar.gz.

File metadata

  • Download URL: image_palette_extractor-0.2.0.tar.gz
  • Upload date:
  • Size: 34.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for image_palette_extractor-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a9fe68ea216ddbd66200cc9567841b634cd54b2fd95dfbde6ad2d6c574de09af
MD5 e604e654a2321fd846655a9c4e8e7411
BLAKE2b-256 bfbb953151da83e6c7ad5007799c477862f67c822afc7bc56ecb64cdac784222

See more details on using hashes here.

File details

Details for the file image_palette_extractor-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for image_palette_extractor-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4c4b322468e5ac11c6de8e5381dc7aa0b9b83b5a715e0c24975441339345c46
MD5 35fbd386345d9075f576139a8c83c88e
BLAKE2b-256 11a10d0ec2647a905b705b8a2ac8d20962b758d01a9f48b894a6ca282b76e7ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page