有趣的二維碼:用 MyQR 和 qrcode 制作二維碼
點(diǎn)擊上方藍(lán)字關(guān)注我們
來源: 夏悠然然 https://blog.csdn.net/qq_42730750/article/details/108877378
1. 二維碼
pip install MyQR
if __name__ == '__main__': version, level, qr_name = myqr.run( words='https://xxx.com/ccc', version=1, level='H', picture='./XKD.gif', colorized=True, contrast=1.0, brightness=1.0, save_name='test4.gif', save_dir=os.getcwd() )print(version)print(level) print(qr_name)
-
數(shù)字 0 到 9 -
大小寫的英文字母 -
常用英文標(biāo)點(diǎn)符號(hào)和空格
3. qrcode
pip install qrcode
def mergeImg(img1, img2, flag=True):""" 合并圖像 :param img1: :param img2: :param flag: True 表示將logo居中, False 表示將logo作為背景圖 :return: """ img1_w, img1_h = img1.sizeif flag: img2_w = int(img2.size[0] / 3) img2_h = int(img2.size[1] / 3)# 縮放logo img2 = img2.resize(size=(img2_w, img2_h), resample=Image.ANTIALIAS)# 將logo居中顯示 img1.paste(im=img2, box=(int((img1_w - img2_w) / 2), int((img1_h - img2_h) / 2))) img1.save('./test8.png')else: img2 = img2.resize(size=(img1_w, img1_h), resample=Image.ANTIALIAS)# 兩張圖片的size和mode要一致# 計(jì)算公式為out = image1 * (1.0 - alpha) + image2 * alpha# 這里的背景色就是一種干擾了, 如果將二維碼的透明度設(shè)置過高會(huì)識(shí)別不出來 out_img = Image.blend(img1, img2, alpha=0.3) out_img.save('./test9.png')
if __name__ == '__main__': qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_H, box_size=10, border=4, ) qr.add_data('https://xxx.com/ccc') qr.make(fit=True)
# black green purple orange pink white blue# make_image() 返回的是一個(gè)PilImage對(duì)象# 可以使用pillow對(duì)它進(jìn)行圖像處理相關(guān)的操作# img1 = qr.make_image(fill_color="#8A2BE2", back_color="white") img1 = qr.make_image(fill_color="orange", back_color="white").convert('RGB')# img1.show()# img1.save('./test6.png')
img2 = Image.open('./cutcamera.png').convert('RGB') mergeImg(img1, img2, flag=True)
回復(fù)下方 「關(guān)鍵詞」,獲取優(yōu)質(zhì)資源
回復(fù)關(guān)鍵詞 「linux」,即可獲取 185 頁 Linux 工具快速教程手冊(cè)和154頁的Linux筆記。
回復(fù)關(guān)鍵詞 「Python進(jìn)階」,即可獲取 106 頁 Python 進(jìn)階文檔 PDF
回復(fù)關(guān)鍵詞 「Python面試題」,即可獲取最新 100道 面試題 PDF
回復(fù)關(guān)鍵詞 「python數(shù)據(jù)分析」,即可獲取47頁python數(shù)據(jù)分析與自然語言處理的 PDF
回復(fù)關(guān)鍵詞 「python爬蟲」,滿滿五份PPT爬蟲教程和70多個(gè)案例
回復(fù)關(guān)鍵詞 「Python最強(qiáng)基礎(chǔ)學(xué)習(xí)文檔」,即可獲取 168 頁 Python 最強(qiáng)基礎(chǔ)學(xué)習(xí)文檔 PDF,讓你快速入門Python
回復(fù)關(guān)鍵詞 「linux」,即可獲取 185 頁 Linux 工具快速教程手冊(cè)和154頁的Linux筆記。
回復(fù)關(guān)鍵詞 「Python進(jìn)階」,即可獲取 106 頁 Python 進(jìn)階文檔 PDF
回復(fù)關(guān)鍵詞 「Python面試題」,即可獲取最新 100道 面試題 PDF
回復(fù)關(guān)鍵詞 「python數(shù)據(jù)分析」,即可獲取47頁python數(shù)據(jù)分析與自然語言處理的 PDF
回復(fù)關(guān)鍵詞 「python爬蟲」,滿滿五份PPT爬蟲教程和70多個(gè)案例
推薦我的微信號(hào)
來圍觀我的朋友圈,我的經(jīng)驗(yàn)分享,技術(shù)更新,不定期送書,坑位有限,速速掃碼添加!
備注:開發(fā)方向_昵稱_城市,另送你10本Python電子書。![]()
![]()
點(diǎn)個(gè)在看你最好看
評(píng)論
圖片
表情
