PHPackages                             hasbridge/php-color - 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. hasbridge/php-color

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

hasbridge/php-color
===================

Color utility class for PHP 5.3 that allows for easy conversion between RGB, HSV, XYZ, and Lab colorspaces, as well as color comparison

27.8k2[1 PRs](https://github.com/matthewbaggett/php-color/pulls)PHPCI failing

Since Feb 9Pushed 4y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

PHP Color Utility Class
=======================

[](#php-color-utility-class)

[![Travis CI](https://camo.githubusercontent.com/ce40630a5238050d08183b756393621b979cf8315871cd52f462a52800386b81/68747470733a2f2f7472617669732d63692e6f72672f6d617474686577626167676574742f7068702d636f6c6f722e737667)](https://camo.githubusercontent.com/ce40630a5238050d08183b756393621b979cf8315871cd52f462a52800386b81/68747470733a2f2f7472617669732d63692e6f72672f6d617474686577626167676574742f7068702d636f6c6f722e737667) [![Code Climate](https://camo.githubusercontent.com/d0f09d7f8546908a0890a81c2f315de5303052cc9c56680d454932a5f76b5c80/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d617474686577626167676574742f7068702d636f6c6f722f6261646765732f6770612e737667)](https://codeclimate.com/github/matthewbaggett/php-color) [![Test Coverage](https://camo.githubusercontent.com/7bd62c5225e35a803af1dff15a90fc5841751905a596829d4d927e49e950629d/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d617474686577626167676574742f7068702d636f6c6f722f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/matthewbaggett/php-color)

This class is intended to make it easier to convert between colorspaces, as well as compare one color to another.

Requirements
------------

[](#requirements)

- PHP 5.3 or greater (closure support is required)

Examples:
---------

[](#examples)

### Initialize object (using hex notation is easier if you are familiar with CSS colors):

[](#initialize-object-using-hex-notation-is-easier-if-you-are-familiar-with-css-colors)

```
$color = new Color(0xFFFFFF);

```

### Get distance from another color using the RGB colorspace:

[](#get-distance-from-another-color-using-the-rgb-colorspace)

```
$color1 = new Color(0xFFFFFF);
$color2 = new Color(0x888888);

$distance = $color1->getDistanceRgbFrom($color2);

```

### Get closest matching color using the Lab(CIE) colorspace:

[](#get-closest-matching-color-using-the-labcie-colorspace)

```
$color = new Color(0xFFFFFF);

$palette = array(
    0x000000,
    0x888888,
    0xAAAAAA
);

$matchIndex = $color->getClosestMatch($palette);
$matchColor = $palette[$matchIndex];

```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75.8% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5707be384b9daab9858223c5dfead9d692e8b5f6afa8dd23ad5c5cbc149316b2?d=identicon)[matthewbaggett](/maintainers/matthewbaggett)

---

Top Contributors

[![matthewbaggett](https://avatars.githubusercontent.com/u/943948?v=4)](https://github.com/matthewbaggett "matthewbaggett (25 commits)")[![hasbridge](https://avatars.githubusercontent.com/u/647090?v=4)](https://github.com/hasbridge "hasbridge (4 commits)")[![dVelopment](https://avatars.githubusercontent.com/u/591304?v=4)](https://github.com/dVelopment "dVelopment (1 commits)")[![fahmiardi](https://avatars.githubusercontent.com/u/1201482?v=4)](https://github.com/fahmiardi "fahmiardi (1 commits)")[![jedateach](https://avatars.githubusercontent.com/u/1356335?v=4)](https://github.com/jedateach "jedateach (1 commits)")[![Josiah](https://avatars.githubusercontent.com/u/77621?v=4)](https://github.com/Josiah "Josiah (1 commits)")

### Embed Badge

![Health badge](/badges/hasbridge-php-color/health.svg)

```
[![Health](https://phpackages.com/badges/hasbridge-php-color/health.svg)](https://phpackages.com/packages/hasbridge-php-color)
```

###  Alternatives

[crodas/languagedetector

simple library to classify texts

320263.9k](/packages/crodas-languagedetector)[ahand/mobileesp

Since 2008, MobileESP provides web site developers an easy-to-use and lightweight API for detecting whether visitors are using a mobile device, and if so, what kind. The APIs provide simple boolean results ('true' or 'false') for identifying individual device categories (such as iPhone, BlackBerry, Android, and Windows Mobile), device capabilities (e.g., J2ME), and broad classes of devices, such as 'iPhone Tier' (iPhone/Android/Tizen) or 'Tablet Tier.' APIs are available in PHP, JavaScript, Java, C#, Ruby Python, and more.

173518.7k9](/packages/ahand-mobileesp)[ibrahimbougaoua/filament-rating-star

This is my package filament-rating-star

42110.2k1](/packages/ibrahimbougaoua-filament-rating-star)[automattic/maintenance-mode-wp

Shut down your site for a little while and do some maintenance on it!

501.8k](/packages/automattic-maintenance-mode-wp)[twc/maker-bundle

Wrap maker bundle to introduce context option to change destination template

1418.0k](/packages/twc-maker-bundle)

PHPackages © 2026

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