Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
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()
Ejemplo n.º 3
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()
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
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)
Ejemplo n.º 8
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
Ejemplo n.º 9
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")