コード例 #1
1
ファイル: functions.py プロジェクト: gfdipert/GB-QR-Code-Game
def makeQR(url, filename, form):
	"""Create and save QR code for phrase piece."""
	outfolder = getoutfolder(form['guide_id'].value())
	qr = QRCode()
	qr.add_data(url)
	im = qr.make_image()
	im.save(outfolder+"/"+filename, 'png')
コード例 #2
0
ファイル: bot.py プロジェクト: mqt2r/web-wechat-bot
 def login(self):
     if self.qrlogin_uuid is None:
         self.qrlogin_uuid = self._get_qrlogin_uuid()
     qr = QRCode(border=2)
     qr.add_data('https://login.weixin.qq.com/l/{}'.format(self.qrlogin_uuid))
     qr.make(fit=True)
     qr.print_ascii(invert=True)
     self._start_login()
コード例 #3
0
 def to_qr_code(self):
     import qrcode
     from qrcode.main import QRCode
     qr = QRCode(
         version=1,
         box_size=1,
         border=4,  # min spec is 4
         error_correction=qrcode.constants.ERROR_CORRECT_L,
     )
     qr.add_data(bytes(self))
     qr.print_ascii()
コード例 #4
0
def run_example(data="http://www.lincolnloop.com", *args, **kwargs):
    """
    Build an example QR Code and display it.

    There's an even easier way than the code here though: just use the ``make``
    shortcut.
    """
    qr = QRCode(*args, **kwargs)
    qr.add_data(data)

    im = qr.make_image()
    im.show()
コード例 #5
0
ファイル: __init__.py プロジェクト: 0x5e/python-qrcode
def run_example(data="http://www.lincolnloop.com", *args, **kwargs):
    """
    Build an example QR Code and display it.

    There's an even easier way than the code here though: just use the ``make``
    shortcut.
    """
    qr = QRCode(*args, **kwargs)
    qr.add_data(data)

    im = qr.make_image()
    im.show()
コード例 #6
0
def gen_qr_svgimage(vcard, qr_path):
    qr = QRCode(image_factory=SvgPathImage)
    qr.add_data(vcard)
    # img = qr.make_image(image_factory=SvgPathImage)
    img = qr.make_image(fit=True)
    # NOTE: img.get_image() will return a lxml svg element,
    # but without the qr path element.
    # Probably there is other way to obtain it other than having to save
    # the image
    # img.save(six.BytesIO())
    img.save(qr_path)
    logger.info('QRCode generated in %s, width: %s', qr_path, img.width)
    return img, img.width
コード例 #7
0
def get_qr_code(data, **kwargs):

    im_name = kwargs.pop("image", None)

    qr = QRCode(**kwargs)
    qr.add_data(data)
    qr_image = qr.make_image()
    if im_name:
        im = image_resize(im_name, 60)
        x = qr_image.size[0] / 2 - im.size[0] / 2
        # If the modes don’t match, the pasted image is converted to the mode of
        # this image.
        # The qr_image mode is 1, the im mode is RGB,
        # We must convert the mode first to let the im looks colorful.
        qr_image = qr_image.convert(im.mode)
        qr_image.paste(im, (x, x))
    return qr_image
コード例 #8
0
ファイル: util.py プロジェクト: 52server/learn_web
def get_qr_code(data, **kwargs):

    im_name = kwargs.pop("image", None)

    qr = QRCode(**kwargs)
    qr.add_data(data)
    qr_image = qr.make_image()
    if im_name:
        im = image_resize(im_name, 60)
        x = qr_image.size[0]/2 - im.size[0]/2
        # If the modes don’t match, the pasted image is converted to the mode of
        # this image.
        # The qr_image mode is 1, the im mode is RGB,
        # We must convert the mode first to let the im looks colorful.
        qr_image = qr_image.convert(im.mode)
        qr_image.paste(im, (x, x))
    return qr_image
コード例 #9
0
ファイル: view.py プロジェクト: lzxz1234/Utilities
def qrcode(request):
    qr = QRCode(
        version=1,
        error_correction=constants.ERROR_CORRECT_L,
        box_size=10,
        border=4,
    )
    if 'p' in request.POST:
        qr.add_data(request.POST['p'])
    elif 'p' in request.GET:
        qr.add_data(request.GET['p'])
    else :
        return HttpResponse()
    qr.make(fit=True)
    response = HttpResponse()
    qr.make_image().save(response, "PNG")
    return response
コード例 #10
0
ファイル: py.py プロジェクト: siavashMehran/URL-thing
def make_my_QRcode_bitch(qrData: str,
                         saveAdress: str = '',
                         format: str = 'PNG',
                         saveit: bool = False):

    from qrcode.image.pil import PilImage
    from qrcode.main import QRCode

    myQrCode = QRCode(border=4, box_size=10, image_factory=PilImage)

    myQrCode.add_data(qrData)
    myQrCode.make()
    img = myQrCode.make_image()

    if saveit:
        img.save(stream=saveAdress, format=format)

    return img
コード例 #11
0
ファイル: showqr.py プロジェクト: ricsxn/ShowQR
def main():
	qr = QRCode()
	for line in stdin:
	    qr.add_data(line)
	qr.make()
	im = qr.make_image()
	if SHOWTXT is True:
		font = ImageFont.truetype(FONT, FONTSZ, encoding='unic')
		text = BANNER.decode('utf-8')
		head = HEADER.decode('utf-8')
		(txt_width, txt_height) = font.getsize(text)
		(hdr_width, hdr_height) = font.getsize(head)
		(qr_width,qr_height) = im.size
		draw = ImageDraw.Draw(im)
		draw.text(((qr_width-hdr_width)/2, 1),head,font=font)
		draw.text(((qr_width-txt_width)/2, qr_height-txt_height-1),text,font=font) 
	if "-f" in argv:
		im.save('showQR.png','PNG')
	else:
		im.show()
コード例 #12
0
def make_qr_code_image(text, image_factory, qr_code_options=QRCodeOptions()):
    """
    Generates an image object (from the qrcode library) representing the QR code for the given text.

    Any invalid argument is silently converted into the default value for that argument.
    """

    valid_version = _get_valid_version_or_none(qr_code_options.version)
    valid_size = _get_valid_size_or_default(qr_code_options.size)
    valid_error_correction = _get_valid_error_correction_or_default(
        qr_code_options.error_correction)
    from qrcode.main import QRCode
    qr = QRCode(version=valid_version,
                error_correction=valid_error_correction,
                box_size=valid_size,
                border=qr_code_options.border)
    qr.add_data(force_text(text))
    if valid_version is None:
        qr.make(fit=True)
    return qr.make_image(image_factory=image_factory)
コード例 #13
0
def make_my_QRcode_bitch(qrData: str,
                         saveAbsoulutePath: str = 'qrcode',
                         saveit: bool = False,
                         format: str = 'PNG'):

    from qrcode.image.pil import PilImage
    from qrcode.main import QRCode
    from random import randint
    myQrCode = QRCode(border=4, box_size=10, image_factory=PilImage)

    myQrCode.add_data(qrData)
    myQrCode.make()
    img = myQrCode.make_image()

    if saveit:

        if saveAbsoulutePath:
            img.save(stream=saveAbsoulutePath, format=format)
        else:
            name = f"{str(randint(1, 5000))}.{format}"
            img.save(stream=name, format=format)

    return img
コード例 #14
0
ファイル: showqr.py プロジェクト: ricsxn/ShowQR
from sys import stdin
from qrcode.main import QRCode, make
from qrcode.constants import *
from qrcode import image
import ImageFont
import ImageDraw

VER = "1.1"
SHOWTXT = True
FONT = "/Library/Fonts/Courier New.ttf"
FONTSZ = 12
BANNER = "http://ricsxn.duckdns.org/donate.html"
HEADER = "ShowQR v%s" % VER

qr = QRCode()
for line in stdin:
    qr.add_data(line)
qr.make()
im = qr.make_image()
if SHOWTXT is True:
    font = ImageFont.truetype(FONT, FONTSZ, encoding="unic")
    text = BANNER.decode("utf-8")
    head = HEADER.decode("utf-8")
    (txt_width, txt_height) = font.getsize(text)
    (hdr_width, hdr_height) = font.getsize(head)
    (qr_width, qr_height) = im.size
    draw = ImageDraw.Draw(im)
    draw.text(((qr_width - hdr_width) / 2, 1), head, font=font)
    draw.text(((qr_width - txt_width) / 2, qr_height - txt_height - 1), text, font=font)
im.show()
コード例 #15
0
from qrcode.main import QRCode, make
from qrcode.constants import *
from qrcode import image

qr = QRCode(border=1)
qr.add_data("http://192.168.23.7:8080/1")
im = qr.make_image()
im.save("qrcode.png")