python: qrcode

python.exe -m pip install --upgrade pip

pip install segno
pip install qrcode
pip install qrcode-artistic
pip install urlopen
pip install Image
pip install ImageDraw
pip install ImageSequence
pip install consts


https://github.com/heuer/segno/ Python QR Code and Micro QR Code encoder
https://github.com/lincolnloop/python-qrcode Python QR Code image generator
https://github.com/heuer/qrcode-artistic
https://segno.readthedocs.io/en/latest/qrcode-modes.html
https://segno.readthedocs.io/en/latest/artistic-qrcodes.html

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import segno;
# import qrcode;
# import qrcode_artistic;
import io;
from urllib.request import urlopen;
 
 
 
if __name__ == '__main__':
 
     print('hellow geovindu');
     # draw
     video = segno.make('http://www.dusystem.com');
     video.save('geovindu.png', scale = 4);
     geovindu = segno.make('http://www.dusystem.com', error='h');
     #添加底版图片,也可以添加GIF动态图片 涂聚文,geovindu,Geovin Du
     geovindu.to_artistic(background='1.png', target='geovindu2.png', scale=16);
     url = 'https://media.giphy.com/media/HNo1tVKdFaoco/giphy.gif';
     bg_file = urlopen(url);
     geovindu.to_artistic(background=bg_file, target='ringo.gif', scale=10)
 
     # 转方向
     img = geovindu.to_pil(scale=3).rotate(45, expand=True)
     img.save('yellow-geovindu-rotated.png')
     # 底色
     img2 = geovindu.to_pil(scale=4, dark='darkred', data_dark='darkorange',data_light='yellow');
     img2.save('yellow-geovindu-submarin.png')
      
     # 动态的二维码
     url2 = 'https://media.giphy.com/media/mUPQmck5YEisg/giphy.gif';
     bg_file2 = urlopen(url2);
     out = io.BytesIO();
     geovindu.to_artistic(background=bg_file2, target=out, scale=5, kind='gif')

  Visual Studio 2022

 

 

 

 

PyCharm 2021.2.3

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import segno;
# import qrcode;
# import qrcode_artistic;
import io;
from urllib.request import urlopen;
import qrcode;
import qrcode.image.svg;
from qrcode.image.styledpil import StyledPilImage;
#from qrcode.image.styles.moduledrawers.pil import RoundedModuleDrawer;  旧版
from qrcode.image.styles.colormasks import RadialGradiantColorMask;
# qrcode.image.styles.moduledrawers.RoundedModuleDrawer
from qrcode.image.styles.moduledrawers import RoundedModuleDrawer,SquareModuleDrawer
from qrcode.image.styles.colormasks import RadialGradiantColorMask,SquareGradiantColorMask
 
 
 
 
if __name__ == '__main__':
 
     print('hellow geovindu');
     # draw
     video = segno.make('http://www.dusystem.com');
     video.save('geovindu.png', scale = 15);
     geovindu = segno.make('http://www.dusystem.com', error='h');
     #添加底版图片,也可以添加GIF动态图片 涂聚文,geovindu,Geovin Du
     geovindu.to_artistic(background='1.png', target='geovindu2.png', scale=16);
     url = 'https://media.giphy.com/media/HNo1tVKdFaoco/giphy.gif';
     bg_file = urlopen(url);
     geovindu.to_artistic(background=bg_file, target='ringo.gif', scale=18)
 
     # 转方向
     img = geovindu.to_pil(scale=13).rotate(45, expand=True)
     img.save('yellow-geovindu-rotated.png')
     # 底色
     img2 = geovindu.to_pil(scale=15, dark='darkred', data_dark='darkorange',data_light='yellow');
     img2.save('yellow-geovindu-submarin.png')
      
     # 动态的二维码
     url2 = 'https://media.giphy.com/media/mUPQmck5YEisg/giphy.gif';
     bg_file2 = urlopen(url2);
     out = io.BytesIO();
     geovindu.to_artistic(background=bg_file2, target=out, scale=15, kind='gif');
 
     # qrcode
     qr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_L)
     qr.add_data('http://www.dusystem.com')
     # qrcode.image.styles.moduledrawers.RoundedModuleDrawer();
     img_1 = qr.make_image(image_factory=StyledPilImage, module_drawer=RoundedModuleDrawer())
     img_2 = qr.make_image(image_factory=StyledPilImage, color_mask=RadialGradiantColorMask())
     #
     img_3 = qr.make_image(image_factory=StyledPilImage, embeded_image_path="1.png");
     #
     img_4 = qr.make_image(image_factory=StyledPilImage, module_drawer=SquareModuleDrawer(), color_mask=RadialGradiantColorMask(), embeded_image_path="1.png");
     img_1.save("qrcodegeovindu.png");
     img_2.save("qrcodegeovindu2.png");
     img_3.save("qrcodegeovindu3.png");
     img_4.save("qrcodegeovindu4.png");
 
     qrdu = qrcode.QRCode(
        version=1,
        error_correction=qrcode.constants.ERROR_CORRECT_L,
        box_size=18,
        border=4,
      );
 
     dudata="http://www.dusystem.com/";
     qrdu.add_data(dudata);
     qrdu.make(fit=True);
     imgdu = qrdu.make_image(fill_color=( 213 , 143 , 1 ), back_color="lightblue");
     imgdu.save("geovinduqrcode.png");
     

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @   ®Geovin Du Dream Park™  阅读(95)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
历史上的今天:
2021-12-17 java: MySql Connection using JDK 14.02
2021-12-17 java: Lamdba
2015-12-17 css:Media Queries
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示