Problem with colors writing ImageFonts into a 'P'-mode Image
Anthra Norell
anthra.norell at tiscalinet.ch
Tue Apr 19 10:25:49 EDT 2005
Hi all,
I have a problem with writing an ImageFont into a 'P' mode Image.
The letters pick up what look like randomly colored pixels along their edges.
Thanks for any suggestions
Frederic
##########################################################################
The attached picture is one of those that tell more than a thousand words.
The code that made its two components
...
I = Image.new ('P', (10, 10), color = I_EVEN_REDDISH) # okay.
I.putpalette (p) # p: 3 * 256 integers # okay
D = ImageDraw.Draw (I) # okay
D.line ((0,0,50,50), fill = I_ODD_BLUISH) # okay. index
F = ImageFont.truetype (FONT_FILE, font_size) # okay
>>>D.text (F, 'Abc', (0,0), fill = BLACK_I_256) # Not okay? <<<
The second run was a fill color closer to the background color:
>>>D.text (F, 'Abc', (0,0), fill = I_ODD_BLUISH) # Not okay but different! <<<
I_EVEN_REDDISH, I_ODD_BLUISH, BLACK_I_256 are palette indexes somewhere in the range 0 to 255
The attached composite is a manual edit.
The (obvious) problem
The D.text method seems to scatter strangely colored pixels along
the outlines or the letters. These false colors somehow depend on
the fill color (color of the text). Namely, if the fill color approaches
the background color, the confetti get tamer too.
A hunch
Could it be that some aliasing mechanism interpolates palette
indexes instead of color triplets? If I don't load my palette, the
default palette is a linear gray scale and the letters indeed have
aliased outlines. With a linear gray scale, of course, the indexes
are identical with the data they index and so a wrong algorithm
would produce a correct result.
The Configuration
Dell Insprion 8000
Windows ME
Python 2.2.2.
Python Imaging Library 1.1.2
No evidence ever of an improper configuration.
##########################################################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050419/848fdd86/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Abc.zip
Type: application/x-zip-compressed
Size: 4353 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050419/848fdd86/attachment.bin>
More information about the Python-list
mailing list