PHPackages                             ottawadeveloper/coloranalyzer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ottawadeveloper/coloranalyzer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ottawadeveloper/coloranalyzer
=============================

Provides WCAG information about CSS colors.

v0.1(10y ago)012MITPHP

Since Feb 5Pushed 10y ago1 watchersCompare

[ Source](https://github.com/ottawadeveloper/coloranalyzer)[ Packagist](https://packagist.org/packages/ottawadeveloper/coloranalyzer)[ RSS](/packages/ottawadeveloper-coloranalyzer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Color Analyzer
==============

[](#color-analyzer)

This project provides tools to analyze colors from CSS code to see which combinations comply with the W3C's recommended contrast ratio.

As this is a personal project, I've taken the opportunity to make some elements very robust (far robust than they probably need to be) so that it is very extendable by other solutions.

Color Support
-------------

[](#color-support)

Out of the box, this library provides support for:

- 2-digit hex codes that represent a shade of grey
- 3-digit hex codes that represent a web-safe color
- 6-digit hex code colors
- 8-digit hex codes that represent a color with alpha value
- Official CSS color keywords
- Valid calls to rgb(), rgba(), hsl() and hsla()

Other applications who leverage this library can extend the default supported methods by providing an object that implements the ColorProcessor interface and adding it to the ColorFactory.

Reporting Support
-----------------

[](#reporting-support)

Out of the box, this library provides a reporting functionality that allows other applications to define the columns they want to see in a report, as well as a separate formatter. Reports are generated by pairing each color provided with each other color, and then running the report components for each pair. Out of the box, the following columns are supported:

- ColorTextReport: Display the name of the color, using an instance of ColorProcessor to display the color. Note that you have to add it twice to the report: once for the foreground, and once for the background.
- LuminosityContrastReport: Display the luminosity constrast ratio (value between 1 and 21) between the two colors.
- Wcag2ComplianceReport: Displays whether the colors are compliant with either the AA criteria or AAA criteria.

You can add your own reporting columns by implementing the ReportComponent interface and adding an instance of it to your report.

Blending Support
----------------

[](#blending-support)

This library provides support for blending two colors together, and allowing other applications to choose the strategy. By default, the alpha composite method is used (with support for transparent backgrounds as well). Blending is automatically applied to non-opaque colors when calculating the luminosity contrast.

To change the blending strategy, you can implement the ColorBlender interface, and then pass the implementation to the ColorFactory. Only one blending strategy can be used.

Usage
-----

[](#usage)

See example-report.php for an example of generating a report.

License
-------

[](#license)

This project is provided under the MIT license, meaning that you can reuse it as you would like, as long as you keep the LICENSE.txt file with it.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3747d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2d6f5ea58c9bd8ce5b76a5402a9810192fab0ef745ae5222adfc4563317902c?d=identicon)[ottawadeveloper](/maintainers/ottawadeveloper)

---

Top Contributors

[![uottawa-wcms](https://avatars.githubusercontent.com/u/2169590?v=4)](https://github.com/uottawa-wcms "uottawa-wcms (5 commits)")

---

Tags

coloraccessibilitywcagluminosity

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ottawadeveloper-coloranalyzer/health.svg)

```
[![Health](https://phpackages.com/badges/ottawadeveloper-coloranalyzer/health.svg)](https://phpackages.com/packages/ottawadeveloper-coloranalyzer)
```

###  Alternatives

[spatie/color

A little library to handle color conversions

38018.9M28](/packages/spatie-color)[mexitek/phpcolors

A series of methods that let you manipulate colors. Just incase you ever need different shades of one color on the fly.

5003.6M18](/packages/mexitek-phpcolors)[mistic100/randomcolor

Generate attractive random colors

2431.4M6](/packages/mistic100-randomcolor)[kartik-v/yii2-widget-colorinput

An enhanced Yii 2 widget encapsulating the HTML 5 color input (sub repo split from yii2-widgets)

324.8M10](/packages/kartik-v-yii2-widget-colorinput)[ssnepenthe/color-utils

A PHP library for performing SASS-like color manipulations.

631.1M11](/packages/ssnepenthe-color-utils)[tecnickcom/tc-lib-color

PHP library to manipulate various color representations

247.2M9](/packages/tecnickcom-tc-lib-color)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
