9/22/2018

QRcode & Barcode generation example source code by Python



#########################
#qr code creator example
#pip install pillow
#pip install qrcode
#https://pypi.org/project/qrcode/# 
import qrcode
qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)
qr.add_data('http://webapp.marearts.com')
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
img.save("qr.png")


#########################
#barcode creator example
#pip install python-barcode
#https://pypi.org/project/python-barcode/

import barcode
from barcode.writer import ImageWriter
EAN = barcode.get_barcode_class('ean13')
ean = EAN('5901234123457', writer=ImageWriter()) #13 digits number only
fullname = ean.save('barcode')

you can test this source code on here: http://www.marearts.com/webapp/qrcode/






No comments:

Post a Comment