Zain Dana HarperBuild Color · color workbench

Measure and convert digital color.

Build Color measures, converts, compares and transforms digital color: perceptual spaces, HDR tone maps, appearance models, chromatic adaptation, spectral tools, gamut mapping, ICC profiles and LUTs, with an optional GUI.

build-color 1.0.2 · fair-source (FSL-1.1-MIT) · on PyPI · 15+ spaces · 12 tone operators

Why perceptual spaces

Hex codes store raw numbers, so two colors with close hex values can look clearly different, and the reverse. Build Color also works in spaces built to track vision: CIELAB and the Oklab family space colors so equal numeric steps look equally different, CIECAM-style models account for surroundings, and JzAzBz and ICtCp handle bright HDR images.

Examples

Output from build-color 1.0.1.

Exhibit I one color in several spaces
$ build-color info ff6030
Color: #ff6030

  sRGB:       (1.0000, 0.3765, 0.1882)
  XYZ:        (0.4596, 0.2985, 0.0614)
  Lab (D65):  (61.52, 58.31, 56.98)
  Oklab:      (0.6128, 0.8175, 0.0611)
  Oklch:      (0.6128, 0.8198, 4.3)
  Luminance:  0.2984
  Dominant wavelength: 775 nm
  Contrast vs white: 3.01:1   vs black: 6.97:1

Lightness, chroma, hue, luminance, dominant wavelength and text contrast against white and black, with D65 as the reference white.

Exhibit II five color-difference metrics
$ build-color difference ff0000 00ff00 --metric all
Color 1: #ff0000      Color 2: #00ff00

  CIE76         170.1404
  CIE94          74.8681
  CIEDE2000      87.6784
  CMC(2:1)      104.2193
  HyAB          201.1010

Red against green under CIE76, CIE94, CIEDE2000, CMC and HyAB. The metrics disagree, so --metric all shows every one.

Exhibit III a triadic scheme in a perceptual space
$ build-color harmony ff6030 --scheme triadic
Base: #ff6030   Scheme: triadic

  1. #ff6030  (1.000, 0.376, 0.188)
  2. #588a00  (0.349, 0.543, 0.000)
  3. #fe51ff  (0.999, 0.320, 1.000)

Three colors spaced evenly in a perceptual space, so they look evenly apart.

Other commands: convert between any two spaces, spectrum for a color from a color temperature, and icc to write a display profile. Run build-color with no arguments for the GUI.

Spaces, tone maps and metrics

Spaces: sRGB, Linear RGB, XYZ, xyY, CIELAB, LCH, Oklab, Oklch, JzAzBz, JzCzhz, ICtCp, HSV, Display P3, BT.2020, Adobe RGB, ACEScg. HDR tone mapping: ACES (Narkowicz + Hill), AgX (neutral / punchy / golden), Reinhard, Hable/Uncharted 2, Lottes, Uchimura/Gran Turismo, PBR Neutral (Khronos glTF), BT.2390 EETF, BT.2446 Method A, and a custom knee. Difference by CIE76, CIE94, CIEDE2000, CMC, HyAB; chromatic adaptation, color-blindness simulation, gamut mapping, color naming, 3D-LUT I/O.

build-color 1.0.2 is on PyPI under FSL-1.1-MIT (each release converts to MIT after two years) and runs on Python 3.10 or newer. It works on digital color values; measuring a physical screen needs a calibrated instrument.

Install and run it

Python 3.10 or newer.

$ pip install build-color
$ build-color info ff6030            # every space for one color
$ build-color convert ff6030 --to oklab
$ build-color difference ff0000 00ff00 --metric all
$ build-color                         # or launch the GUI
GitHub: HarperZ9/build-color  ·  PyPI: build-color  ·  ← the map  ·  the index