Skip to main content

Python port of the npm colorthief package API for dominant color, palettes, and semantic swatches.

Project description

colorthief-v3

Python 3 package based on the latest npm colorthief API (colorthief@3.3.1).

It extracts dominant colors, palettes, semantic swatches, and rich color objects from images. The Python package uses Pillow for image decoding and keeps the npm package's core option names: color_count, quality, color_space, ignore_white, white_threshold, alpha_threshold, and min_saturation.

Install

pip install .

Usage

from colorthief_v3 import get_color, get_palette, get_swatches

color = get_color("photo.jpg")
print(color.hex())       # "#e84393"
print(color.css())       # "rgb(232, 67, 147)"
print(color.text_color)  # "#000000" or "#ffffff"

palette = get_palette("photo.jpg", color_count=6)
print([c.hex() for c in palette])

swatches = get_swatches("photo.jpg")
print(swatches["Vibrant"].color.hex() if swatches["Vibrant"] else None)

CamelCase aliases are also exported for easier migration from JavaScript: getColor, getPalette, getSwatches, getPaletteProgressive, and createColor.

CLI

colorthief-v3 color photo.jpg --json
colorthief-v3 palette photo.jpg --count 6 --color-space oklch
colorthief-v3 swatches photo.jpg --css

Source

This package was generated from the npm package metadata for colorthief@3.3.1. See vendor/colorthief-npm.json.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

colorthief_v3-3.3.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file colorthief_v3-3.3.1-py3-none-any.whl.

File metadata

  • Download URL: colorthief_v3-3.3.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for colorthief_v3-3.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7c2442ff9acca28fc499462bfc9ec9a9179f6589815d0a5359e87de85a38f266
MD5 1c71e3c27edcc1aee04fa81189a017c7
BLAKE2b-256 3339d2f0411a2414b42ac594f63478009fd6eef32608460d3a9d517ed1a9f514

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