[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