[Python] Alternatives to PIL/Pillow for overlaying an image with text

Discussão em 'Python' iniciado por Stack, Fevereiro 3, 2025.

  1. Stack

    Stack Membro Participativo

    Do any Python alternatives exist for overlaying an image with text? I tried with PIL/Pillow, but the output is really grainy and artifacted.

    Here is my code:

    from PIL import Image
    from PIL import ImageFont
    from PIL import ImageDraw

    img = Image.open("image.jpg")
    draw = ImageDraw.Draw(img)
    font = ImageFont.truetype("Comic Sans MS.ttf", 24)
    draw.text((150, 20),"Sample Text",(170,14,179), font=font)
    img.save('sample-out123.jpg')


    and the output:

    [​IMG]

    You can see artifacting around the text as well as a light purple glow.

    Continue reading...

Compartilhe esta Página