第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在標(biāo)簽上繪制圖像

如何在標(biāo)簽上繪制圖像

慕桂英546537 2022-01-18 16:05:53
我目前正在嘗試在我的標(biāo)簽(pylabels 庫)上繪制二維碼。我可以使用 qrcode 庫創(chuàng)建 qr 代碼圖像。但是,我對如何在標(biāo)簽上實際繪制圖像有點迷茫。我使用了來自https://github.com/bcbnz/pylabels/blob/1.2.1/demos/basic.py的示例代碼我嘗試使用 shape.Drawing 提供的所有方法,但沒有成功。我瀏覽了 reportlab 文檔,但并不真正了解我是如何讓它工作的。def draw_label(label, width, height, obj):    # Just convert the object to a string and print this at the bottom left of    # the label.    config = obj.get('config')    label.add(shapes.String(2, 2, f'{config.get("code")}', fontName="Helvetica", fontSize=10))    label.add(shapes.Drawing.drawOn(label, obj.get('image'), 100, 100))def create_labels():    specs = labels.Specification(210, 297, 4, 5, 45, 45, corner_radius=1)    sheet = labels.Sheet(specs, draw_label, border=True)    for num in range(10000, 10020):        setup_dict = {            'setup': 'setup-config',            'code': num,        }        qr = qrcode.QRCode(            version=1,            error_correction=qrcode.constants.ERROR_CORRECT_H,            box_size=15,            border=5,        )        # Add JSON encoded data to qr code        qr.add_data(json.dumps(setup_dict))        qr.make(fit=True)        qr_code = {            'config': setup_dict,            'image': qr.make_image(fill_color="black", back_color="white"),        }        sheet.add_label(qr_code)        sheet.save('/qr_codes.pdf')如果有人能給我舉個例子,將不勝感激。
查看完整描述

1 回答

?
ABOUTYOU

TA貢獻(xiàn)1812條經(jīng)驗 獲得超5個贊

我能夠弄清楚。我很困惑,以至于我沒有看到明顯的東西。如果您遇到同樣的問題,以下是您需要的。


from reportlab.graphics.shapes import Image


label.add(Image(25, 42, 80, 80, obj.get('image')))


查看完整回答
反對 回復(fù) 2022-01-18
  • 1 回答
  • 0 關(guān)注
  • 161 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號