Color Tools API Reference
Version: 6.5.0
Welcome to the Color Tools API documentation! This library provides comprehensive color science tools for accurate color space conversions, perceptual color distance metrics, and color matching.
🎨 Three Ways to Use Color Tools:
As a library:
from color_tools import rgb_to_labAs a CLI tool:
python -m color_tools color --name coralAs installed command:
color_tools filament --list-makers(needs pip install)
Quick Start
from color_tools import rgb_to_lab, delta_e_2000, Palette
# Convert RGB to LAB
lab = rgb_to_lab((255, 128, 64))
# Find nearest CSS color
palette = Palette.load_default()
nearest, distance = palette.nearest_color(lab)
print(f"Nearest color: {nearest.name}")
Documentation
For comprehensive guides and CLI usage:
📖 Usage Guide - Library and CLI usage examples
⚙️ Installation - Installation instructions
🎨 Customization - User overrides and custom palettes
❓ FAQ - Frequently asked questions
📋 Quick Reference - Command cheat sheet
🔧 Troubleshooting - Common issues and solutions
CLI Commands
The CLI provides six main commands:
color - Search CSS colors by name or find nearest color
filament - Search 3D printing filaments with filtering (maker, type, finish)
convert - Convert between color spaces and check gamut
name - Generate descriptive names for RGB colors
validate - Validate if hex codes match color names (fuzzy matching + Delta E)
Optional: Install
[fuzzy]extra for improved fuzzy matching:pip install color-match-tools[fuzzy]
cvd - Color vision deficiency simulation and correction
image - Image color analysis and manipulation
Requires: Install
[image]extra:pip install color-match-tools[image]
See the Usage Guide for detailed CLI examples.
Data Classes
The library uses immutable dataclasses (frozen) to represent colors, filaments, and results:
ColorRecord - CSS colors with precomputed values in all color spaces
FilamentRecord - 3D printing filaments with intelligent dual-color handling
ColorValidationRecord - Color name/hex validation results with fuzzy matching
ColorCluster - Image color clusters from k-means analysis (requires [image] extra)
ColorChange - Luminance redistribution results for HueForge (requires [image] extra)
All data classes have comprehensive docstrings with attribute descriptions and examples. See the Usage Guide for a quick reference table.
Core API Reference
Color Science
Color space conversion functions. |
|
Color distance metrics for measuring perceptual color differences. |
|
Gamut checking and mapping for sRGB color space. |
|
Immutable color science constants from international standards. |
|
Color transformation matrices for various operations. |
|
Thread-safe runtime configuration for color processing behavior. |
Color & Filament Data
Color palette management with fast lookup. |
|
Filament palette management for 3D printing color matching. |
|
Color naming utilities for generating descriptive names from RGB values. |
|
Color validation functions to check if a hex code matches a color name. |
|
Color vision deficiency simulation and correction. |
Export System
Export system for filaments and colors. |
|
Palette exporter plugin system. |
|
Base classes and metadata for palette exporters. |
|
Generic CSV exporter for colors and filaments. |
|
JSON format exporter for colors and filaments. |
|
GIMP Palette (.gpl) format exporter. |
|
Hex format exporter. |
|
JASC-PAL format exporter. |
|
AutoForge filament library CSV exporter. |
|
Lospec JSON palette format exporter. |
|
PAINT.NET palette format exporter. |
Image Processing (requires [image] extra)
Image processing module for color_tools. |
|
Image analysis functions for color extraction and manipulation. |
|
Basic image analysis functions for color_tools. |
|
Photoshop-compatible blend mode operations for image layers. |
|
Image format conversion utilities. |
|
Watermarking functionality for images. |
Command Line Interface
Command-line interface for color_tools. |
|
CLI package for color_tools. |
|
Utility functions for CLI argument parsing and validation. |
|
Reporting and diagnostic utilities for user data and overrides. |
|
Command handlers for color_tools CLI. |
|
Color command handler - Search and query CSS colors. |
|
Convert command handler - Convert between color spaces and check gamut. |
|
CVD command handler - Color vision deficiency simulation and correction. |
|
Filament command handler - Search and query 3D printing filaments. |
|
Image processing command handler. |
|
Name command handler - Generate descriptive color names from RGB values. |
|
Validate command handler - Verify color name/hex pairings. |
Optional Features
Interactive filament library manager using prompt_toolkit TUI. |