tecnickcom / tc-lib-color
PHP library to manipulate various color representations
Fund package maintenance!
Requires
- php: >=8.1
- ext-pcre: *
Requires (Dev)
- pdepend/pdepend: ^2.16
- phpcompatibility/php-compatibility: ^10.0.0@dev
- phpmd/phpmd: ^2.15
- phpunit/phpunit: ^13.1 || ^12.5 || ^11.5 || ^10.5
- squizlabs/php_codesniffer: ^4.0
- dev-main
- 2.3.14
- 2.3.13
- 2.3.12
- 2.3.11
- 2.3.10
- 2.3.9
- 2.3.8
- 2.3.7
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.2.19
- 2.2.18
- 2.2.17
- 2.2.16
- 2.2.15
- 2.2.13
- 2.2.12
- 2.2.11
- 2.2.10
- 2.2.9
- 2.2.8
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 1.14.39
- 1.14.38
- 1.14.37
- 1.14.35
- 1.14.34
- 1.14.33
- 1.14.32
- 1.14.31
- 1.14.29
- 1.14.28
- 1.14.27
- 1.14.26
- 1.14.25
- 1.14.24
- 1.14.23
- 1.14.22
- 1.14.21
- 1.14.20
- 1.14.19
- 1.14.18
- 1.14.17
- 1.14.16
- 1.14.15
- 1.14.14
- 1.14.13
- 1.14.10
- 1.14.9
- 1.14.8
- 1.14.7
- 1.14.6
- 1.14.1
- 1.14.0
- 1.12.15
- 1.12.14
- 1.12.13
- 1.12.12
- 1.12.11
- 1.12.10
- 1.12.9
- 1.12.8
- 1.12.7
- 1.12.6
- 1.12.5
- 1.12.4
- 1.12.3
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.2
- 1.11.0
- 1.10.3
- 1.10.2
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.18
- 1.6.17
- 1.6.16
- 1.6.15
- 1.6.14
- 1.6.13
- 1.6.12
- 1.6.11
- 1.6.10
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.5
- 1.4.4
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.10
- 1.0.9
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2026-04-20 07:13:14 UTC
README
PHP color toolkit for conversion and normalization across common color models.
If this library helps your graphics workflow, please consider supporting development via PayPal.
Overview
tc-lib-color provides utilities for parsing, converting, and formatting color values used in web and PDF rendering pipelines.
The library is designed to centralize color logic so applications avoid ad-hoc conversion code and rounding drift across modules. It provides a consistent normalization layer that helps keep visual output aligned between browser previews and final PDF rendering.
| Namespace | \Com\Tecnick\Color |
| Author | Nicola Asuni info@tecnick.com |
| License | GNU LGPL v3 - see LICENSE |
| API docs | https://tcpdf.org/docs/srcdoc/tc-lib-color |
| Packagist | https://packagist.org/packages/tecnickcom/tc-lib-color |
Features
Color Models
- RGB/RGBA and hexadecimal color handling
- HSL/HSLA and CMYK conversion workflows
- Grayscale and spot color support
Integration Helpers
- CSS-ready color output
- PDF-oriented color conversion helpers
- Named web color lookup and normalization
Requirements
- PHP 8.1 or later
- Extension:
pcre - Composer
Installation
composer require tecnickcom/tc-lib-color
Quick Start
<?php require_once __DIR__ . '/vendor/autoload.php'; $web = new \Com\Tecnick\Color\Web(); $rgb = $web->getRgbObjFromHex('#336699'); echo $rgb->getCssColor();
See example/index.php for a complete conversion showcase.
Development
make deps
make help
make qa
Packaging
make rpm make deb
For system packages, bootstrap with:
require_once '/usr/share/php/Com/Tecnick/Color/autoload.php';
Contributing
Contributions are welcome. Please review CONTRIBUTING.md, CODE_OF_CONDUCT.md, and SECURITY.md.
Contact
Nicola Asuni - info@tecnick.com