Skip to content

draw.text() function generate pure black word? #3591

@lxsyz

Description

@lxsyz

What did you do?

I want to add pure black text on a image with white background.

What did you expect to happen?

The whole image just has two kinds of color: black and white.

What actually happened?

At the edge of the words on generated image, many other colors appears.

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: 3.5
  • Pillow: 5.3.0
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')

tim 20190118174110

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions