[Image-SIG] Bad antialias in PIL 1.1.5
Laszlo Zsolt Nagy
gandalf at designaproduct.biz
Mon Sep 19 10:10:01 CEST 2005
I create a fully transparent red image this way:
size = (400,400)
img = Image.new('RGBA',size,(255,0,0,0))
Then I draw an (antialiased) text on it:
drawer = ImageDraw.Draw(img)
font = ImageFont.truetype('arc.ttf',12)
drawer.text((0,0),"This text is 12pt",font=font,fill=(0,0,0,255))
This is what I get (image drawn on a gray background):
http://mess.hu/download/bad_antialias.png
Apparently, antialiasing will use a mixture of the background color and
the text color on the edges.
I think this is good only if the background is fully opaque. The good
solution is (of course) is to
use the antialiased B&W text as an alpha channel, apply it to a fully
opaque rectangle (using text color),
and finally make a composite of the target image and the antialiased
text. Is there a faster workaround
for this problem than crop, new, composite, paste?
Is this a PIL bug or a feature?
Thanks,
Les
More information about the Image-SIG
mailing list