Douglas, Thank you for help. Now it works great if I write a text from the top, e.g. to write the text 20 pixel from left and 20 from the top. I use textpos=(20,20) But I would like to write the text to the lower left bottom, starting 30 pixels from left and 30 from the bottom. So I use textpos=(im.size[0]-30,im.size[1]-30) but it does not work. There si no text written. Can you please tell me why? Thank you Lad.
> [EMAIL PROTECTED] wrote: > > > 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? > > As Amos Newcombe pointed out, this is not what you really want. If > you still want to try, something like this would be easiest: > > # complement the whole image > comp = im.point(lambda x: 255 - x) > > # make a text mask -- a black image with white writing > mask = Image.new('L', im.size, 0) > font = ImageFont.load_default() > draw = ImageDraw.Draw(mask) > draw.text((5, 5), "hello hello", fill="white") > > #paste the complementary image over the original, using the text as a > #mask. > im.paste(comp, (0,0), mask) > > To follow Paul Svensson's suggestion, you would do the same, but with > a different overlay image. > > inverse_threshold = im.point((([255]*128) + ([0]*128)) * 3) > > and paste that instead of the complementary image. But I think the > clearest way, based on watching subtitled movies, is to have the text > in a constant colour, with an outline, or shadow, or glow. So I would > try instead: > > blur = mask.filter(ImageFilter.BLUR) > im.paste((0,0,0), (0,0), blur) > im.paste((255,255,255), (0,0), mask) > > for white writing with a black halo. Maybe black on white is better. > > > douglas > > > > > _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig