In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to use MyQR and qrcode to make QR code in python". The editor shows you the operation process through an actual case. The method of operation is simple, fast and practical. I hope that this article "how to use MyQR and qrcode to make QR code in python" can help you solve the problem.
One-and two-dimensional codes
QR code (2 − Dimensional (2-Dimensional (2 − Dimensional Barcode), also known as 2D barcode. It records the information of data symbols by using a black-and-white figure distributed in the plane (two-dimensional direction) according to a certain rule. In the programming of the code, the concepts of "0" and "1" bit streams, which constitute the logic basis of the computer, are skillfully used to represent the text numerical information by using several geometric shapes corresponding to the binary system. automatic information processing is realized by automatic reading by image input equipment or photoelectric scanning equipment.
one-dimensional bar code, which is what we call bar code (Barcod) (Barcod) (Barcod), is common in food packaging. It is a graphical identifier that arranges multiple black stripes and blanks with different widths according to certain coding rules to express a set of information. The common one-dimensional bar code is a parallel line pattern arranged by black stripes (abbreviated to stripes) and white stripes (referred to as blank). The bar code can mark the country of production, manufacturer, commodity name, production date, as well as book classification number, e-mail start and end place, category, date and other information.
usually can represent only 10 digits, 26 English letters and some special characters in one-dimensional bar code. The maximum number of characters represented by the bar code character set is 128 ASCII characters, so the amount of information is very limited.
two-dimensional code has its own specific character set, each character occupies a certain width, and each kind of code has a certain function of checking. At the same time, it also has the function of automatically identifying the information of different peers, and dealing with the rotation of graphics.
two-dimensional bar code is a bar code that stores information horizontally and vertically in two-dimensional space. Its advantages are large information capacity, high decoding reliability, strong error correction ability, low production cost, good security and anti-counterfeiting performance.
At present, the most widely used two-dimensional bar code symbols in the world are Aztec Code, PDF147, QR Code and so on.
The common QR code is QR CodeCode,QR, whose full name is Quick Response, which is a very popular coding method on mobile devices in recent years.
QR Code belongs to matrix two-dimensional bar code, also known as chessboard two-dimensional bar code. It is encoded in a rectangular space by the different distributions of black and white pixels in the matrix. In the position of the corresponding elements of the matrix, the binary "1" is represented by the appearance of points (square dots, dots or other shapes), and the absence of dots represents the binary "0". The permutation and combination of points determines the meaning represented by the matrix two-dimensional bar code.
The main characteristics are as follows:
Symbol specifications range from version 1 (21 × 21) to version 40 (177 × 177). Each version is increased by 4 symbols on each side (that is, the square black and white dots that make up the QR code).
Large information capacity: can store 7089 numeric characters or 4296 alphabetic characters or 2953 8-bit byte characters or 1817 Chinese characters
Strong error correction ability: even if part of the code becomes dirty or damaged, the data can be recovered. About 7% of the data codewords can be corrected at L level, 15% at M level, 25% at Q level, and 30% at H level.
It can be read from any direction: QR code can be read quickly from any direction of 360 °. Through the three positioning patterns in the QR code, it can help the QR code not to be affected by the background style and achieve fast and stable reading.
II. MyQR
MyQR can generate common QR codes, artistic QR codes (black and white or color), and dynamic QR codes (black and white or color). The installation commands are as follows:
Pip install MyQR-I http://pypi.douban.com/simple-- trusted-host pypi.douban.com
The code is as follows
If _ _ name__ ='_ _ main__': version, level, qr_name = myqr.run (words=' https://blog.csdn.net/qq_42730750', 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)
these are some of the QR codes I generated:
MyQR is really easy to use, the only disadvantage is that it does not support Chinese! Yes, isn't it a pity that it only supports the following characters:
The numbers 0 to 9
Uppercase and lowercase letters
Commonly used English punctuation marks and spaces
III. Qrcode
Although the function of qrcode is slightly lower than that of MyQR, it supports Chinese characters and can generate vector diagrams. The installation commands are as follows:
Pip install qrcode-I http://pypi.douban.com/simple-- trusted-host pypi.douban.com
The QR code is generated as follows:
Def mergeImg (img1, img2, flag=True): "" merge image: param img1:: param img2:: param flag: True means to center logo, and False means to use logo as background image: return: "" img1_w " Img1_h = img1.size if flag: img2_w = int (img2.size [0] / 3) img2_h = int (img2.size [1] / 3) # Zoom logo img2 = img2.resize (size= (img2_w, img2_h), resample=Image.ANTIALIAS) # Center logo to display 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) # the size and mode of the two images should be the same # the calculation formula is out = image1 * (1.0-alpha) + image2 * alpha # the background color here is a kind of interference. 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) will not be recognized if the transparency of the QR code is set too high. ) qr.add_data ('this is my blog address: https://blog.csdn.net/qq_42730750') qr.make (fit=True) # black green purple orange pink white blue # make_image () returns a PilImage object # you can use pillow for image processing related operations # 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) about how to use MyQR and qrcode to make QR codes in python Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.