I want to add pure black text on a image with white background.
The whole image just has two kinds of color: black and white.
At the edge of the words on generated image, many other colors appears.
directory_name = "dataset/guwen_noise"
target_name = "dataset/watermark"
image = Image.new(mode='L', size=(64, 64), color='white')
draw_table = ImageDraw.Draw(im=image)
draw_table.text(xy=(0, 0), text='xxsad', fill='#000000', font=ImageFont.truetype(os.path.join("fonts", "Microsoft-YaHei-Regular.ttc"), 20))
image.save('my_test.png', 'PNG')

As we can see, many pixels are filled with other color. And I find it's useless to modify the "mode" parameter. I would appreciate it very much if you could help me!
Let's get this clear: you want to disable antialiasing?
Try to set draw_table.fontmode = "1"
Most helpful comment
Let's get this clear: you want to disable antialiasing?