PHP - How to convert RGB color to CIE 1931 color specification
I am creating my own PHP based application where i want to change RGB color into xy format of CIE 1931. How can i convert my RGB color specs to the CIE color space? Philipp First calculate X, Y and Z with the transform matrix and then normalize the result X = 0.4124*R + 0.3576*G + 0.1805*B Y = 0.2126*R + 0.7152*G + 0.0722*B Z = 0.0193*R + 0.1192*G + 0.9505*B Normalize: x = X / (X + Y + Z) y = Y / (X + Y + Z) Here is my Javascript version. It should help you enough ;) /** * Convert RGB to XY */ function RGBtoXY(red,green,blue){ red = (red > 0.04045) ? Math.pow((red + 0.055) / (1.0 + 0.055), 2.4