473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PIL and font colour

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.

Apr 24 '07 #1
3 3592
Johny wrote:
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

Apr 25 '07 #2
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

Apr 26 '07 #3
py****@hope.cz wrote:
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 see that you had an answer to this question on the PIL list, so I will
merely note that it's difficult if the background color turns out close
to mid-gray, or if it's very variable. In general this is a hard
problem. Are you sure it wouldn't be easier to just put a colored strip
behind the text and in front of the image?

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

Apr 26 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Louise | last post by:
Hi I have written an HTML pages which does not have any colour specifying tags as far I know. When I view this in an Microsoft internet explorer browser it appears with a white background and...
3
by: amber | last post by:
Hello, I have a textbox that needs to have red font. I also want it set to enable=false, or else 'read-only'. When I change to either of these settings, the font turns black. Is there a way...
3
by: Muffinman | last post by:
Hi, I'm trying to build a script which will fade the colour of my text to another. Now I've got here a litte problem. Whene ever I want to replace one of the numbers in:...
1
by: Tull Clancey | last post by:
Hi All. I want to be able to change the font colour of certain rows in a Net.Datagird. The data source is a manually created data table within a set. I can format all the columns just the...
0
by: Badino | last post by:
Hi, Can someone tell me what to put in this code so that if a user selects 0 (Black) then make the font white (0) as my default colour is black on my Excel spreadsheet. Private Type...
0
by: Johny | last post by:
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...
0
by: Johny | last post by:
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...
4
by: gaya3 | last post by:
Hi all, In my program, i have like <td> <a href=url1> link1</a> <a href=url2> link2</a> <a href=url3> link3</a> </td> problem is i have to change the font colour of...
3
by: DNolan | last post by:
Hello, I was wondering if anyone could help me. I have an access form with tabbed pages on it. I would like the colour of the tab name to change when a user inputs information into the fields on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.