1

I have created a small python script to generate a bunch of QR Codes using pyqrcode and using PIL to write the QR code value just below the QR code. The text is being written to the image using the following code:

def writeText(img,text):
    img = Image.open(img)
    draw = ImageDraw.Draw(img)
    w,h = img.size

    font = ImageFont.truetype('/Library/Fonts/Arial Black.ttf',20)
    text_w,text_h = draw.textsize(text,font)

    draw.text(((w-text_w) // 2, h-text_h-12), text,font=font)

    img.save("new.png")

The output text on the image is not smooth (see image) and the edges are not smooth lines. How can I achieve a high quality text on the image. Any changes in the code?

Example Output

Aneesh Relan
  • 342
  • 3
  • 12

0 Answers0