PIL and font colour.

python at hope.cz python at hope.cz
Thu Apr 26 09:17:05 CEST 2007


Steve
 Thank you for your reply.
 
 Is there a way how to find out a complementary colour for an area where I will write the text, so 
 that the text will be seen clearly?Is there a routine in PIL or in Python somewhere?
 Thank you for help
 
 Lad.
 



> >  I use PIL to write some text to a picture.The text must  be seen wery
> > clearly.
> > I write the text to different pictures but to the same position. As
> > pictures maybe  different, colour, in the position where I write the
> > text, is also different.
> > Is there a way how to set the font colour so that it will be seen very
> > clearly in the picture?
> > For example, if the picture is bright ( for example yellow), the font
> > colour should be dark( e.g. black) and vice versa.
> > Can anyone help?
> > Thanks
> > L.
> > 
> The easy way to ensure this is to paint a background rectangle of an 
> appropriate color to ensure good font contrast before writing the text. 
> Of course, this obscures rather more of the image in the background than 
> you might otherwise.
> 
> Apart from that you could try averaging the pixel values in the area you 
> are going to paint on, and then choose a font color that contrasts well 
> with the average. If there are large variations in color, however, this 
> can give disappointing results.
> 
> If you'd like to get some insight into color contrast you could do worse 
> than start at
> 
>    http://wellstyled.com/tools/colorscheme2/index-en.html
> 
> regards
>   Steve
> -- 
> Steve Holden       +1 571 484 6266   +1 800 494 3119
> Holden Web LLC/Ltd          http://www.holdenweb.com
> Skype: holdenweb     http://del.icio.us/steve.holden
> Recent Ramblings       http://holdenweb.blogspot.com
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list