示例#1
0
def generateQRImageForUrl(url):
    qr_image = pyqrcode.MakeQRImage(
        url,
        errorCorrectLevel=pyqrcode.QRErrorCorrectLevel.H,
        block_in_pixels=1,
        border_in_blocks=0)
    return qr_image
示例#2
0
文件: codebar.py 项目: rechner/Taxidi
def gen(encoding, fileName, text, width=300, height=100):
    """Returns 0 success; all else are errors.
    gen(encoding, fileName, text, width=300, height=100)
    note: geometry settings only valid for code128.
    """

    if encoding not in codes:
        raise NotImplementedError("Unsupported encoding")
        return 2

    if encoding == 'qr':
        #generate QR code
        qr_image = pyqrcode.MakeQRImage(text, br=True)
        fileHandle = file(fileName, 'w')
        qr_image.save(fileHandle, 'PNG')
        fileHandle.close()
        return 0

    elif encoding == 'code128':
        #generate using Code128() by Jostein Leira
        bar = Code128()
        bar.getImage(text, fileName, 300, 100)
        return 0

    else:
        #generate barcode
        pre = barcode.get_barcode(encoding, text, writer=ImageWriter())
        save = pre.save(fileName)

        out = Image.open(save)
        #crop the image
        if encoding == 'code39':
            out = out.crop((28, 10, out.size[0] - 24, 180))
        os.unlink(save)
        fileHandle = file(fileName, 'w')
        out.save(fileHandle, 'PNG')
        fileHandle.close()
        return 0
示例#3
0
import pyqrcode
import uuid
import Image

for i in xrange(10,99):
	qr = pyqrcode.MakeQRImage(str(uuid.uuid4()), 3)
	qr = qr.resize((100,100), Image.ANTIALIAS)
	qr.save("qrcode0%d.png" % i, "PNG")
示例#4
0
 def setQrCode(self, uri):
     qrcode = ImageQt.ImageQt(
         pyqrcode.MakeQRImage(uri, block_in_pixels=5, border_in_blocks=0))
     pixmap = QtGui.QPixmap.fromImage(qrcode)
     self.qrCodeContainer.setPixmap(pixmap)
示例#5
0
import pyqrcode

URL = "http://www.discoveranywheremobile.com/"
URL = "http://m.visitpalmsprings.com/listings/x-1fe89fc957e563c7/x-08cdb36014211c43/l-22c2cdd72d95ff48/"

qr_image = pyqrcode.MakeQRImage(URL,
                                rounding=5,
                                fg="black",
                                bg="burlywood",
                                br=False)
qr_image.show()