tilecharbox.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:handfontgen 作者: nixeneko 项目源码 文件源码
def _getqrtag(self, text, rect):
        qr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_L)
        qr.add_data(text)
        qr.make(fit=True)
        img = qr.make_image()
        bio = io.BytesIO()
        img.save(bio)

        pngqr = bio.getvalue()
        base64qr = base64.b64encode(pngqr)
        #<image x="110" y="20" width="280px" height="160px" xlink:href="data:image/png;base64,……"/>
        imagetag = ElementTree.Element("image")
        imagetag.set("xlink:href", "data:image/png;base64,"+base64qr.decode("ascii"))
        imagetag.set("x", str(rect.x))
        imagetag.set("y", str(rect.y))
        imagetag.set("width", str(rect.w))
        imagetag.set("height", str(rect.h))
        return imagetag
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号