Home Blog Convert an XYZ Color to CIELAB Color Space with PHP

Convert an XYZ Color to CIELAB Color Space with PHP


In 1931, CIE (Commission Internationale de l’Eclairage) defined the CIE XYZ color space, representing all possible colors based on human perception. Like RGB, CIE XYZ has three orthogonal dimensions; however, X, Y and Z do not correspond to real colors – they are mathematically convenient with Y carrying the luminance information. CIE is usually represented by a 2D “chromaticity diagram” obtained from the CIE XYZ model.

Image: The most commonly used system in practical application, aside from the CIE color triangle, is the nearly perception-true L*, a*, b* system that was developed by Judd and Hunter and standardized in 1976. In this system, the L* value indicates the position on the light-dark axis, the a* value indicates the position on the red/green axis, and the b* value indicates the position on the blue/yellow axis).

Convert an XYZ Color to CIELAB Color Space with PHP

The L*, a*, b* coordinates are correlated directly to the standard color values, X, Y, and Z. Source: Zeiss .

The CIE XYZ model and chromaticity diagram are not perceptually uniform. A more uniform version of CIE was defined in 1976, officially known as CIE L*a*b*. L* stands for luminance, a* is the red-green axis, and b* is the blue-yellow axis (referred to as CIELAB). The asterisks were added to differentiate CIE from the Hunter Lab model which is more commonly referred to as Hunter CIE to avoid additional confusion.

Although CIE L*a*b* has a large color gamut and is considered the most accurate color model, it is more commonly used solely as a reference or intermediary for color space conversion. In practice, the RGB and CMYK color spaces are more widely used for display and printing, and HSB and HSL are used for color selection. However, all color spaces, including RGB, CMYK, HSB, HSL and YUV, are subsets of the entire human color gamut as measured and defined by CIE.

The PHP function on this page will convert CIE XYZ to CIELAB.

The PHP Function


  • The pre tags in the example code above need to be closed (they were removed for page formatting purposes). The download includes working code.
  • We have a number of color posts scheduled (and published) that’ll work with color data in various ways; they will all be available via the color Tag: color tag.


Title: Convert an XYZ Color to CIELAB Color Space with PHP
Description: Convert an XYZ Color to CIELAB Color Space with PHP.
Download: PHP Code (V0.2) | Plugin Page

Shortt URL for this post: http://shor.tt/1XN5


Please enter your comment!
Please enter your name here