QR code is widely used on internet, python provides some libraries to create qr code. In this tutorial, we will introduce to how to create qr code with image backgourd using myqr library.
Install python myqr library
You can use pip to install this library.
Create a qr code without image background
We can create a common qr code using myqr library, you can refer to this example code.
from MyQR import myqr url = 'https://www.tutorialexample.com' qr_file = 'tutorial_qr.png' myqr.run(words = url, picture = logo, save_name = qr_file)
In code above, we will create a qr code, the content of which is ‘https://www.tutorialexample.com‘, we save this qr code to file tutorial_qr.png.
Open tutorial_qr.png, you will find qr code like this:
Create a qr code with image background
We can find the qr code above has no background, we also can use myqr to create a qr code with an image as background.
from MyQR import myqr url = 'https://www.tutorialexample.com' qr_file = 'tutorial_qr_with_logo.png' logo = 'logo.png' myqr.run(words = url, picture = logo, colorized = True, save_name = qr_file)
Run this code, we will find our qr code like: