0

I have a project to generate qr code with logo in center of qr code. How I can make it like this.

enter image description here

now I'm use django-qr-code to generate text qr code but I need qr code with logo in center.

  • This has been asked a number of times. See https://stackoverflow.com/questions/45481990/how-to-insert-logo-in-the-center-of-qrcode-in-python for example. Please do a search before asking questions to ensure that it hasn't already been answered. – Kemp Jan 27 '21 at 14:47

1 Answers1

0

If you use a high-redundancy algorithm (eg H), you can damage the generated QRCode up to a certain percentage. H means you can cover 30% of the data and it'll still work.

That means it's just a case of placing your image over the code. The format is up to you.

import pyqrcode
from PIL import Image
url = pyqrcode.QRCode('http://www.eqxiu.com',error = 'H')
url.png('test.png',scale=10)
im = Image.open('test.png')
im = im.convert("RGBA")
logo = Image.open('logo.png')
box = (135,135,235,235)
im.crop(box)
region = logo
region = region.resize((box[2] - box[0], box[3] - box[1]))
im.paste(region,box)
im.show()
Revisto
  • 1,211
  • 7
  • 11