splitbrain.org
Submitted by: David Walsh

Calculating Color Contrast with PHP

A good designer will choose high contrast colors for backgrounds and texts without hesitation. But sometimes no human is involved in choosing the colors. For example when colors are assigned in a (pseudo) random manner.

After some Googling I found a page explaining different color contrast algorithms. I used the data from that page and implemented 3 color check functions in PHP.

direct link