1

Does anyone know how to change the color of text to white when the image is "dark" and black when the image is "light"?

I need this because my background is pulled from flickr and I can't guarantee what it'll be!

Here is what i've got so far

GeorgeTaylor
  • 63
  • 1
  • 2
  • 7
  • Added link. fiddle doesn't work due to libraries used – GeorgeTaylor May 03 '14 at 10:08
  • http://stackoverflow.com/questions/17346405/automatically-contrasting-text-color-based-on-background-image-color – Er.KT May 03 '14 at 10:09
  • http://stackoverflow.com/questions/13762864/image-dark-light-detection-client-sided-script – Jesse May 03 '14 at 10:09
  • possible duplicate of [How to decide font color in white or black depending on background color?](http://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color) – underscore May 03 '14 at 10:11

1 Answers1

0

You can do this using the "canvas" tag with a simple function located here -> http://jsfiddle.net/s7Wx2/

source: Image Dark/Light Detection Client Sided Script

getImageLightness("image.jpg",function(brightness){
    console.log(brightness);
});
Community
  • 1
  • 1
Jesse
  • 2,790
  • 1
  • 20
  • 36