I'm doing a ODP->HTML conversion with PHP. I have problems with the following:
Use the style:use-window-font-color property to specify whether or not the window foreground color should be as used as the foreground color for a light background color and white for a dark background color.
(OpenDocument specification version 1.0, 15.4.4)
If i have a background image, how do i check, if this image is light or dark?
Do you have any ideas?
Thanks in advance, Levu
I thought this was quite an interesting problem to solve, so i hacked up a quick script to do it. following the other suggestions provided
you could possibly use some image processing algorithm that would examine the pixel brightness and calculate mean image brightness.
this document will get you started:
http://www.kweii.com/site/color_theory/2007_LV/BrightnessCalculation.pdf
If you're looking to use GD, trying using
imagecolorat
to sample pixels of the image. You can determine the RGB of the color as shown on the PHP man page.Next, take the RGB sample(s) and determine their brightness using a basic luminance formula.
Determine a threshold for what you consider light vs. dark and categorize accordingly.