Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

qrcode how to add logo inside python

# import modules
import qrcode
from PIL import Image
 
# taking image which user wants
# in the QR code center
Logo_link = 'g4g.jpg'
 
logo = Image.open(Logo_link)
 
# taking base width
basewidth = 100
 
# adjust image size
wpercent = (basewidth/float(logo.size[0]))
hsize = int((float(logo.size[1])*float(wpercent)))
logo = logo.resize((basewidth, hsize), Image.ANTIALIAS)
QRcode = qrcode.QRCode(
    error_correction=qrcode.constants.ERROR_CORRECT_H
)
 
# taking url or text
url = 'https://www.geeksforgeeks.org/'
 
# adding URL or text to QRcode
QRcode.add_data(url)
 
# generating QR code
QRcode.make()
 
# taking color name from user
QRcolor = 'Green'
 
# adding color to QR code
QRimg = QRcode.make_image(
    fill_color=QRcolor, back_color="white").convert('RGB')
 
# set size of QR code
pos = ((QRimg.size[0] - logo.size[0]) // 2,
       (QRimg.size[1] - logo.size[1]) // 2)
QRimg.paste(logo, pos)
 
# save the QR code generated
QRimg.save('gfg_QR.png')
 
print('QR code generated!')
Comment

PREVIOUS NEXT
Code Example
Python :: what does bin do in python 
Python :: how to convert ordereddict to dict in python 
Python :: numpy subtraction operation using numpy functions 
Python :: change the Values to Numpy Array 
Python :: prevent not admin from visiting a url tornado python 
Python :: Python DateTime Time Class syntax 
Python :: scraped text in Russian encoding python 
Python :: lol infinite print in python 
Python :: python break string to sections 
Python :: how to save a from with createvue django 
Python :: Generate bootstrap replicate of 1D data that return a particular operation 
Python :: python list as stacks 
Python :: python regular expression path 
Python :: svm classification involving pipelines 
Python :: get mismatch element in allclose numpy 
Python :: access dictionary in f string 
Python :: scatter plot python color according to gender 
Python :: Python3 code to find Triangular Number Series   
Python :: get a list of colors that appear of the image python 
Python :: delta lake with spark 
Python :: how to import modules from upper or previous dir in py 
Python :: python multi arguments 
Python :: Creaing your own functions 
Python :: pandas set index integer not float 
Python :: como inserir um elemento num set em python 
Python :: picobot python 
Python :: how to maximize pandas output python 
Python :: print fps in while loop python 
Python :: quando è stata inventata la lavastoviglie 
Python :: dorp ligne in df where values equal zeros 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =