Use CIEDE2000 as the general default for Lab-based perceptual comparison. Choose another formula only when an existing specification or validated workflow requires it, and never reuse a numeric threshold across formulas without new evidence.
Measure perceptual color distance
ColorDistance::deltaE() calculates CIEDE2000 distance:
use PhpColor\Color\Color;
use PhpColor\Color\Distance\ColorDistance;
$reference = Color::parse('#2563eb');
$candidate = Color::parse('#1d4ed8');
$distance = ColorDistance::deltaE($reference, $candidate);
use PhpColor\Color\Color;
use PhpColor\Color\Distance\ColorDistance;
$reference = Color::parse('#2563eb');
$candidate = Color::parse('#1d4ed8');
$distance = ColorDistance::deltaE($reference, $candidate);
Both colors are converted to Lab for the calculation. Identical colors produce zero; larger values indicate greater difference under the chosen formula.
Do not assign a universal meaning such as “indistinguishable” or “acceptable” to a single Delta E value. Useful thresholds depend on the formula, medium, viewing conditions, observers, and the application’s tolerance. Establish thresholds with representative samples for your own workflow.
Select a distance algorithm
ColorDistance::calculate() defaults to CIEDE2000 and accepts these case-insensitive identifiers:
| Algorithm | Accepted identifiers |
|---|---|
| CIEDE2000 | 'CIEDE2000', 'DE2000' |
| Delta E 94 | 'DeltaE94', 'DE94' |
| CMC acceptability, 2:1 | 'CMC', 'CMC(2:1)' |
| CMC perceptibility, 1:1 | 'CMC(1:1)' |
use PhpColor\Color\Color;
use PhpColor\Color\Distance\ColorDistance;
$distance = ColorDistance::calculate(
Color::parse('#2563eb'),
Color::parse('#1d4ed8'),
'DE94',
);
use PhpColor\Color\Color;
use PhpColor\Color\Distance\ColorDistance;
$distance = ColorDistance::calculate(
Color::parse('#2563eb'),
Color::parse('#1d4ed8'),
'DE94',
);
An unknown string throws PhpColor\Color\Exception\InvalidColorException.
Use the default CIEDE2000 calculation for a general modern Lab-based comparison. Select Delta E 94 or CMC when an existing specification or established workflow requires that formula. Values from different algorithms are not interchangeable.
Define the decision before the threshold
Distance can support duplicate detection, revision review, nearest-color labeling, or tolerance checks. Those tasks do not share one pass threshold. Record the formula, reference samples, medium, and consequence of a false match before choosing the number.
Continue with Compare brand revisions with CIEDE2000, Find the nearest palette token, or Measure color distance.