Example #1
0
def get_qrcode(data):
    """
    Return a QR Code PNG (binary data)
    """
    height = width = 250
    code = QRChart(height, width)
    code.set_ec('L', 0)  # "Level L" error correction with a 0 pixel margin
    code.add_data(data)
    with get_temp_file() as (__, fname):
        code.download(fname)
        with open(fname, "rb") as f:
            png_data = f.read()
    return png_data
Example #2
0
def get_qrcode(data):
    """
    Return a QR Code PNG (binary data)
    """
    height = width = 250
    code = QRChart(height, width)
    code.set_ec('L', 0)  # "Level L" error correction with a 0 pixel margin
    code.add_data(data)
    with get_temp_file() as (__, fname):
        code.download(fname)
        with open(fname, "rb") as f:
            png_data = f.read()
    return png_data
Example #3
0
def hello():

    # Create a 250x250 QR chart
    chart = QRChart(250, 250)

    # Add the text
    chart.add_data('Hello, World!')

    # "Level H" error correction with a 0 pixel margin
    chart.set_ec('H', 0)

    # Download
    chart.download('qr-hello.png')
Example #4
0
def get_qr_code_from_google():
    from pygooglechart import QRChart
    
    # Create a AxA QR code chart
    chart = QRChart(126, 126)
    
    # Add the text
    chart.add_data('ID:1234|Info: foobar')
    
    # "Level H" error correction with a 0 pixel margin
    chart.set_ec('H', 0)
    
    # Download
    chart.download('1.png')
Example #5
0
def parse_data(data, out_prefix):
    chart = QRChart(SIZE, SIZE)
    chart.add_data(data.strip())
    chart.set_ec('H', 0)

    out_fmt = out_prefix + '_{:03d}.png'
    count = 0
    out_file = out_fmt.format(count)
    while os.path.exists(out_fmt.format(count)):
        count += 1
        out_file = out_fmt.format(count)

    print 'Saving {}'.format(out_file)
    chart.download(out_file.format(count))
Example #6
0
    def createVCard(self, data):
        try:
                logging.debug("In create vCard")
                chart = QRChart(HEIGHT, WIDTH)
                templateData = ''
                for k, v in data.items():
                    templateData = self._templateData.replace('{%s}' % k, v)
                    self._templateData = templateData

                match = re.sub(r'{\w*\w}', '', templateData)

                chart.add_data(match)
                chart.set_ec('H', 0)
                uid = uuid.uuid1()
                filePath =  '%s/../static/cache/%s.png' % (os.path.dirname(__file__), uid)
                logging.debug("Creating image: " + filePath)
                chart.download(filePath)
                return uid
        except ex:
                logging.debug('Unhandled exception')
                logging.exception('Unhandled exception')
Example #7
0
 def create_qrcode_image(self):
     chart = QRChart(SHORTIM_QRCODE_SIZE, SHORTIM_QRCODE_SIZE)
     chart.add_data(self.get_short_full_url())
     chart.set_ec('L', 0)
     chart.download(self.get_qrcode_path())
Example #8
0
def doQr(text,fichier):
	chart = QRChart(125,125)
	chart.add_data(text)
	chart.set_ec('H',0)
	chart.download(fichier)