Skip to main content

Comprehensive color science library for accurate color space conversions, perceptual color distance metrics (Delta E), and color matching with CSS and 3D printing filament databases

Project description

Color Tools

A comprehensive Python library for color science operations, color space conversions, and color matching. This tool provides perceptually accurate color distance calculations, gamut checking, and extensive databases of CSS colors and 3D printing filament colors.

Version: 6.5.0 | Changelog

📚 Documentation

📖 Full API Documentation - Complete API reference with examples

User Guides

Document Description
Installation Setup, dependencies, development install
Usage Library API, CLI commands, examples
Customization Data files, custom palettes, configuration
Troubleshooting Error handling, performance, technical notes
FAQ Color spaces, distance metrics, contributing

✨ Features

  • Multiple Color Spaces: RGB, HSL, LAB, LCH with accurate conversions
  • Perceptual Color Distance: Delta E formulas (CIE76, CIE94, CIEDE2000, CMC, HyAB)
  • Color Databases:
    • Complete CSS color names with hex/RGB/HSL/LAB/LCH values
    • Extensive 3D printing filament database (584 filaments) with manufacturer info
    • Unique semantic IDs for all filaments (e.g., "bambu-lab-pla-silk-red")
    • Alternative name support for regional variations and rebranding
    • Maker synonym support for flexible filament searches
    • Retro/Classic Palettes: CGA, EGA, VGA, and Web-safe color palettes
  • Image Transformations (with [image] extra):
    • Color Vision Deficiency (CVD): Simulate and correct for colorblindness (protanopia, deuteranopia, tritanopia)
    • Palette Quantization: Convert images to retro palettes (CGA, EGA, VGA, Game Boy) with dithering support
    • Unified Architecture: All transformations leverage existing color science infrastructure
  • Gamut Checking: Verify if colors are representable in sRGB
  • Thread-Safe: Configurable runtime settings per thread
  • Color Science Integrity: Built-in verification of color constants

🚀 Quick Start

Installation

# Base package (zero dependencies)
pip install color-match-tools

# With image processing support
pip install color-match-tools[image]

# With interactive filament library manager
pip install color-match-tools[interactive]

# With all optional features
pip install color-match-tools[all]

See Installation Guide for development setup and detailed options.

CLI Usage

# Interactive wizard — guided prompts for color, filament, and convert
# (requires: pip install color-match-tools[interactive])
color-tools
color-tools --interactive

# Find a CSS color by name
color-tools color --name coral

# Find nearest CSS color to an RGB value
color-tools color --nearest --value 255 128 64 --space rgb

# Find matching 3D printing filaments
color-tools filament --nearest --value 255 128 64

# Convert between color spaces
color-tools convert --from rgb --to lab --value 255 128 64
color-tools convert --from rgb --to cmyk --value 255 128 64
color-tools convert --from cmyk --to rgb --value 0 50 75 0

# Simulate colorblindness on an image
color-tools image --file photo.jpg --cvd-simulate deuteranopia

# Convert image to retro CGA palette
color-tools image --file photo.jpg --quantize-palette cga4 --dither

Library Usage

from color_tools import rgb_to_lab, delta_e_2000, Palette, FilamentPalette

# Convert RGB to LAB
lab = rgb_to_lab((255, 128, 64))
print(f"LAB: {lab}")

# Find nearest CSS color
palette = Palette.load_default()
nearest, distance = palette.nearest_color(lab, space="lab")
print(f"Nearest: {nearest.name} (ΔE: {distance:.2f})")

# Find matching filaments
filament_palette = FilamentPalette.load_default()
filament, distance = filament_palette.nearest_filament((255, 128, 64))
print(f"Filament: {filament.maker} {filament.color}")

See Usage Guide for complete API reference and CLI documentation.

🎨 Color Spaces

Space Description Range
RGB Red, Green, Blue 0-255 per component
HSL Hue, Saturation, Lightness H: 0-360°, S: 0-100%, L: 0-100%
LAB Perceptually uniform L: 0-100, a/b: ±100
LCH Cylindrical LAB L: 0-100, C: 0+, H: 0-360°
CMY Subtractive (no black channel) C/M/Y: 0-100% each
CMYK Subtractive print model (with black) C/M/Y/K: 0-100% each

Use LAB or LCH for color matching - they're designed to match human perception. Use CMYK for print workflows - the K channel produces richer blacks than CMY alone.

📏 Distance Metrics

Metric Use Case
CIEDE2000 (de2000) Recommended - Gold standard for perceptual accuracy
CIE94 (de94) Good balance of accuracy and performance
CIE76 (de76) Fast, simple Euclidean in LAB space
CMC (cmc) Textile industry standard
HyAB (hyab) Best for large color differences and image quantization

See FAQ for detailed explanations of when to use each metric.

📦 Data Files

The library includes extensive color databases:

  • CSS Colors: 147 named colors with full color space representations
  • 3D Printing Filaments: 584+ filaments from major manufacturers
  • Retro Palettes: 20 official palettes including CGA, EGA, VGA, Game Boy, Commodore 64, PICO-8, and more

Extend with your own data using User Data Files.

Track your owned filaments for personalized color matching - create an owned-filaments.json file to automatically filter searches to filaments you already have. See Owned Filaments in the Customization Guide.

🔧 Export & Integration

Export colors and filaments to various formats for use with external tools:

Available Formats

Universal Formats (Colors + Filaments):

  • CSV - Generic CSV with all fields (preserves full metadata)
  • JSON - Raw data format for backup/restore (preserves full metadata)

Palette/Graphics Applications (Colors Only):

  • GIMP Palette (.gpl) - Import into GIMP, Inkscape, Krita
  • Hex (.hex) - Simple hex color list (uppercase, no # prefix)
  • JASC-PAL (.pal) - Paint Shop Pro palette format (compatible with Aseprite)
  • PAINT.NET (.txt) - PAINT.NET palette format (AARRGGBB hex codes)
  • Lospec JSON (.json) - Lospec.com palette format for sharing palettes

3D Printing (Filaments Only):

  • AutoForge (.csv) - Specialized CSV for AutoForge/HueForge lithophane workflow

Note: Palette formats (Hex, JASC-PAL, PAINT.NET, Lospec) only export color values and lose filament metadata (maker, type, finish, TD values). For full filament data preservation, use CSV or JSON.

Export Examples

from color_tools import Palette, FilamentPalette
from color_tools.exporters import get_exporter, list_export_formats

# List available formats for colors
formats = list_export_formats('colors')
print(formats)
# {'csv': '...', 'json': '...', 'gpl': '...', 'hex': '...', 'pal': '...', ...}

# Export to various formats
palette = Palette.load_default()

# GIMP Palette for graphics work
get_exporter('gpl').export_colors(palette.records[:20], 'colors.gpl')

# Hex format for web/programming
get_exporter('hex').export_colors(palette.records[:20], 'colors.hex')

# JASC-PAL for Paint Shop Pro/Aseprite
get_exporter('pal').export_colors(palette.records[:20], 'colors.pal')

# Lospec JSON for sharing online
get_exporter('lospec').export_colors(palette.records[:20], 'palette.json')

# Export filaments to AutoForge CSV
filaments = FilamentPalette.load_default()
bambu_pla = filaments.filter(maker="Bambu Lab", type_name="PLA")
get_exporter('autoforge').export_filaments(bambu_pla, 'bambu_pla.csv')

Plugin Architecture

The exporter system uses a plugin architecture - new formats can be added without modifying existing code:

from color_tools.exporters import register_exporter
from color_tools.exporters.base import PaletteExporter, ExporterMetadata

@register_exporter
class MyExporter(PaletteExporter):
    @property
    def metadata(self):
        return ExporterMetadata(
            name='myformat',
            description='My custom format',
            file_extension='txt',
            supports_colors=True,
            supports_filaments=False,
        )
    
    def _export_colors_impl(self, colors, output_path):
        # Implementation here
        pass

See exporters/gpl_exporter.py for a complete example.

�🔒 Data Integrity

All core data files are protected with SHA-256 hashes:

python -m color_tools --verify-all

See Troubleshooting for verification details.

🤝 Contributing

CRITICAL: Color science constants should NEVER be modified. They represent fundamental values from international standards.

See FAQ for contribution guidelines.

📄 License

MIT License - see LICENSE for details.

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

color_match_tools-6.5.0.tar.gz (180.1 kB view details)

Uploaded Source

Built Distribution

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

color_match_tools-6.5.0-py3-none-any.whl (207.6 kB view details)

Uploaded Python 3

File details

Details for the file color_match_tools-6.5.0.tar.gz.

File metadata

  • Download URL: color_match_tools-6.5.0.tar.gz
  • Upload date:
  • Size: 180.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for color_match_tools-6.5.0.tar.gz
Algorithm Hash digest
SHA256 b331659a4c2d5459bf2ffa3ac15819e4e64f6716ed1a5fbddc8c29e0e5c44d8c
MD5 4965dec64823b991b6b9a1726fa63e1c
BLAKE2b-256 4940d797535e5b830aa6f735fa4ae0b1064c54a988b7731bbc7efe97538dcd73

See more details on using hashes here.

File details

Details for the file color_match_tools-6.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for color_match_tools-6.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f34cbef9103753d133d912c5d8a07b22b84824963b38ad5e66817e9c516a6d85
MD5 c872bec31c05cbdb2c5d5251ff7cd462
BLAKE2b-256 b38d4ee1960c9cee3ad76631c0ec562804a05cd98edacc4ac9a164ef0284708d

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