PHPackages                             itwmw/color-difference - 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. itwmw/color-difference

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

itwmw/color-difference
======================

Color difference：Din99,CIE76,CIE1994,CIEDE2000,CMC l:c

v1.2.0(4y ago)178.7k2Apache-2.0PHPPHP ^8.1

Since Jan 13Pushed 4y agoCompare

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

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

Color Difference
----------------

[](#color-difference)

[![License](https://camo.githubusercontent.com/fcf4570a2adf8061b3023c389ed17da04ab1ab9f14ca2b960b75e6c65ee6849c/68747470733a2f2f69636f6e2e6974776d772e636f6d2f62616467652f4c6963656e73652d4170616368652d2d322e302d626c7565)](https://camo.githubusercontent.com/fcf4570a2adf8061b3023c389ed17da04ab1ab9f14ca2b960b75e6c65ee6849c/68747470733a2f2f69636f6e2e6974776d772e636f6d2f62616467652f4c6963656e73652d4170616368652d2d322e302d626c7565)[![PHP Version Support](https://camo.githubusercontent.com/6acb94f640a0588dacfde4ce7e34faff4da8f2a85a8942b4a411477f90389391/68747470733a2f2f69636f6e2e6974776d772e636f6d2f62616467652f5048502d253545382e312d677265656e3f6c6f676f3d706870266c6f676f436f6c6f723d76696f6c6574)](https://camo.githubusercontent.com/6acb94f640a0588dacfde4ce7e34faff4da8f2a85a8942b4a411477f90389391/68747470733a2f2f69636f6e2e6974776d772e636f6d2f62616467652f5048502d253545382e312d677265656e3f6c6f676f3d706870266c6f676f436f6c6f723d76696f6c6574)

A library for calculating the perceptual difference between colors (∆E). The difference or distance between two colors is a metric of interest in color science. It allows quantified examination of a notion that formerly could only be described with adjectives. Quantification of these properties is of great importance to those whose work is color-critical. Common definitions make use of the Euclidean distance in a device independent color space.

The following measurements are supported:

- Euclidean
- Weighted Euclidean
- DIN99 (2007)
- CIE76 (1976)
- CIE94 (1994)
- CIEDE2000 (2000)
- CMC l:c (1984)

All calculations are performed in either L\*a\*b\* or L\*C\*H\* space (as the metrics prescribe).

Quick Start
-----------

[](#quick-start)

This library is available on packagist, like so:

```
composer require itwmw/color-difference
```

Usage
-----

[](#usage)

The color difference metrics are implemented via the following functions:

- Euclidean RGB `getDifferenceEuclideanRGB(Color $color): float`
- Euclidean Lab `getDifferenceEuclideanLab(Color $color): float`
- Weighted Euclidean RGB `getDifferenceWeightedEuclideanRGB(Color $color): float`
- Din99 `getDifferenceDin99(Color $color): float`
- CIE76: `getDifferenceCIE76(Color $color): float`
- CIE94: `getDifferenceCIE94(Color $color, CIE94 $type = CIE94::GraphicArts): float`
- CIEDE2000: `getDifferenceCIEDE2000(Color $color): float`
- CMC l:c: `getDifferenceCMC(Color $color, CMC $type = CMC::Imperceptibility): float`

```
use Itwmw\ColorDifference\Color;
use Itwmw\ColorDifference\Lib\RGB;
use Itwmw\ColorDifference\Support\CIE94;
use Itwmw\ColorDifference\Support\CMC;

$color  = new Color(new RGB(255, 183, 255));
$color2 = new Color(new RGB(55, 65, 53));
echo('Din99:' . $color->getDifferenceDin99($color2) . "\n");
echo('CIE76:' . $color->getDifferenceCIE76($color2) . "\n");
echo('CIE94-GraphicArts:' . $color->getDifferenceCIE94($color2, CIE94::GraphicArts) . "\n");
echo('CIE94-Textiles:' . $color->getDifferenceCIE94($color2, CIE94::Textiles) . "\n");
echo('CMC-Acceptability:' . $color->getDifferenceCMC($color2, CMC::Acceptability) . "\n");
echo('CMC-Imperceptibility:' . $color->getDifferenceCMC($color2, CMC::Imperceptibility) . "\n");
echo('CIEDE2000:' . $color->getDifferenceCIEDE2000($color2) . "\n");
echo('Euclidean RGB:' . $color->getDifferenceEuclideanRGB($color2) . "\n");
echo('Euclidean Lab:' . $color->getDifferenceEuclideanLab($color2) . "\n");
echo('Weighted Euclidean RGB:' . $color->getDifferenceWeightedEuclideanRGB($color2) . "\n");
```

CIE94 and CMC l:c accept an optional parameter adjusting the metric for the kind of quasimetric being evaluated. CIE94 offers an application type choice of either 'graphicArts' or 'textiles' for their eponymous use. CMC l:c offers a threshold choice of either 'acceptability' or 'imperceptibility' that nuances the just-noticeable difference between the colors.

Reference White
---------------

[](#reference-white)

Use `referenceWhite` to specify Reference White for the Color class Support:

- A; //Incandescent/tungsten
- B; //Old direct sunlight at noon
- C; //Old daylight
- D50; //ICC profile PCS
- D55; //Mid-morning daylight
- D65; //Daylight, sRGB, Adobe-RGB
- D75; //North sky daylight
- E; //Equal energy
- F1; //Daylight Fluorescent
- F2; //Cool fluorescent
- F3; //White Fluorescent
- F4; //Warm White Fluorescent
- F5; //Daylight Fluorescent
- F6; //Lite White Fluorescent
- F7; //Daylight fluorescent, D65 simulator
- F8; //Sylvania F40, D50 simulator
- F9; //Cool White Fluorescent
- F10; //Ultralume 50, Philips TL85
- F11; //Ultralume 40, Philips TL84
- F12; //Ultralume 30, Philips TL83

```
new Color(new RGB(255, 183, 255), referenceWhite: ReferenceWhite::D65);
```

RGB Working Space
-----------------

[](#rgb-working-space)

Use `RGBSpace` to specify RGB Working Space for the Color class Support:

- Adobe RGB (1998)
- AppleRGB
- Best RGB
- Beta RGB
- Bruce RGB
- CIE RGB
- ColorMatch RGB
- Don RGB 4
- ECI RGB
- Ekta Space PS5
- NTSC RGB
- PAL/SECAM RGB
- ProPhoto RGB
- SMPTE-C RGB
- sRGB
- Wide Gamut RGB

```
new Color(new RGB(255, 183, 255), RGBSpace: RGBSpace::sRGB_D65);
```

> In general, `RGB Working Space` needs to correspond to `Reference White`.

The default is:

```
new Color(new RGB(255, 183, 255), referenceWhite: ReferenceWhite::D65, RGBSpace: RGBSpace::sRGB_D65);
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

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

Every ~0 days

Total

3

Last Release

1584d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4d8c7cd0a79ae4a225651cbd75d83faa585f8e8d909322db9b52fd176949562f?d=identicon)[itwmw](/maintainers/itwmw)

---

Top Contributors

[![moniang](https://avatars.githubusercontent.com/u/61287199?v=4)](https://github.com/moniang "moniang (9 commits)")[![YepYuYu](https://avatars.githubusercontent.com/u/84311710?v=4)](https://github.com/YepYuYu "YepYuYu (1 commits)")

---

Tags

cie76cie94cmclccolor-differencedin99din99CIEDE2000cie76cie94color differenceCIE1976CIE1994CMCCMClcCIE2000CIE00Delta E

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/itwmw-color-difference/health.svg)

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

###  Alternatives

[fjw/color-compare

A library for converting colors (Hex, RGB, HSL, CIELAB (LAB), DIN-99) and calculating color distances based on DIN-99.

1310.0k](/packages/fjw-color-compare)[components/modernizr

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user's browser.

10254.3k8](/packages/components-modernizr)

PHPackages © 2026

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