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

 

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

 

 

 

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 @ 2022-12-17 13:02  ®Geovin Du Dream Park™  阅读(113)  评论(0)    收藏  举报